/* ===================================================================
   PT. Hansoll Indo Java — 워싱동 INVOICE 시스템
   Design System A (HIJ 인원현황 대시보드와 동일한 브랜드 시스템)
   =================================================================== */

@font-face {
  font-family: 'SCDream';
  font-weight: 300;
  font-style: normal;
  src: url('/static/fonts/SCDream-Light.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'SCDream';
  font-weight: 500;
  font-style: normal;
  src: url('/static/fonts/SCDream-Medium.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'SCDream';
  font-weight: 700;
  font-style: normal;
  src: url('/static/fonts/SCDream-Bold.woff2') format('woff2');
  font-display: swap;
}

:root {
  --primary: #01479D;
  --primary-light: #2E73C4;
  --primary-deep: #012E66;
  --primary-pale: #EAF1FB;

  --accent: #F5A623;
  --accent-light: #F9C46B;
  --accent-pale: #FEF3E0;

  --ink: #0F2340;
  --sub: #5C6B85;
  --line: #E1E8F2;
  --bg: #F4F7FB;
  --card: #FFFFFF;

  --red: #C0524A;
  --red-pale: #FBE9E7;
  --green: #5A9A3D;
  --green-pale: #EAF5E4;

  /* 이전 이름과의 호환 (기존 클래스에서 참조) */
  --navy: var(--primary);
  --navy-dark: var(--primary-deep);
  --gold: var(--accent);
  --border: var(--line);
  --text: var(--ink);
  --muted: var(--sub);
  --danger: var(--red);
  --success: var(--green);
}

* { box-sizing: border-box; }

body {
  font-family: 'SCDream', "Malgun Gothic", -apple-system, sans-serif;
  font-weight: 500;
  background: var(--bg);
  color: var(--ink);
  margin: 0;
}

h1, h2, h3 { font-family: 'SCDream', sans-serif; font-weight: 700; }
label { font-family: 'SCDream', sans-serif; }

/* ---------------- 헤더 (브랜드 바 + 탭 내비게이션) ---------------- */

.topbar {
  position: relative;
  background: linear-gradient(115deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  overflow: hidden;
}

.topbar-shape {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.08);
  pointer-events: none;
}
.topbar-shape-1 {
  right: -4%;
  width: 34%;
  clip-path: polygon(45% 0, 100% 0, 100% 100%, 15% 100%);
}
.topbar-shape-2 {
  right: 8%;
  width: 16%;
  background: rgba(255, 255, 255, 0.06);
  clip-path: polygon(45% 0, 100% 0, 100% 100%, 15% 100%);
}

.topbar-top {
  position: relative;
  z-index: 1;
  padding: 14px 24px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo-chip {
  background: #fff;
  border-radius: 8px;
  padding: 5px 10px;
  display: inline-flex;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.logo-chip img { height: 22px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 16px; font-weight: 700; letter-spacing: 0.3px; }
.brand-text em { font-style: normal; font-size: 11px; font-weight: 300; opacity: 0.85; }

.user-info { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.user-name { font-weight: 700; }
.dept-pill {
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.3);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}
.logout-link {
  color: #fff; text-decoration: none; font-weight: 500;
  opacity: 0.9; border-left: 1px solid rgba(255,255,255,0.3); padding-left: 12px;
}
.logout-link:hover { opacity: 1; text-decoration: underline; }

.tab-nav {
  position: relative;
  z-index: 1;
  background: rgba(1, 46, 102, 0.28);
  padding: 0 20px;
  display: flex;
  gap: 2px;
  overflow-x: auto;
}
.tab-nav a {
  display: inline-block;
  padding: 11px 18px 9px;
  color: #fff;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 700;
  opacity: 0.78;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tab-nav a:hover { opacity: 0.95; background: rgba(255,255,255,0.06); }
.tab-nav a.active {
  opacity: 1;
  background: rgba(255,255,255,0.14);
  border-bottom: 3px solid var(--accent);
}

/* ---------------- 레이아웃 / 카드 ---------------- */

.container { max-width: 1250px; margin: 24px auto; padding: 0 20px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(15, 35, 64, 0.04);
}

h1 { font-size: 19px; color: var(--primary); margin: 0 0 16px; }
h2 { font-size: 15px; color: var(--primary); margin: 0 0 12px; }

/* ---------------- 표 ---------------- */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 10px; border-bottom: 1px solid var(--line); text-align: left; }

/* Tabel daftar dibuat ringkas agar isi tetap terbaca horizontal. */
.list-table { table-layout: auto; font-size: 12px; }
.list-table th, .list-table td { padding: 8px 7px; }
.list-table th { font-size: 11px; white-space: nowrap; }
.list-table td.nowrap { white-space: nowrap; }
.list-table .btn-sm { padding: 5px 12px; font-size: 12px; }
.list-table th.num, .list-table td.num { text-align: right; }
.list-table td .action-buttons { display: flex; gap: 4px; white-space: nowrap; justify-content: center; }
th {
  background: var(--primary-pale);
  color: var(--primary-deep);
  font-weight: 700;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.2px;
}
tr:hover td { background: var(--accent-pale); }

/* ---------------- 배지 ---------------- */

.badge {
  display: inline-block; padding: 3px 11px; border-radius: 20px;
  font-size: 12px; font-weight: 700;
}
.badge-draft { background: #ECEFF4; color: var(--sub); }
.badge-submitted { background: var(--accent-pale); color: #97600A; }
.badge-approved { background: var(--green-pale); color: var(--green); }
.badge-rejected { background: var(--red-pale); color: var(--red); }

/* ---------------- 버튼 ---------------- */

.btn {
  display: inline-block; padding: 9px 18px; border-radius: 6px; border: none;
  font-family: 'SCDream', sans-serif;
  font-size: 14px; font-weight: 700; cursor: pointer; text-decoration: none;
  color: #fff; background: var(--primary);
  transition: background 0.15s ease;
}
.btn:hover { background: var(--primary-deep); }
.btn-gold { background: var(--accent); color: #fff; }
.btn-gold:hover { background: #D98E12; }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: var(--primary-pale); }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #9c3f38; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ---------------- 폼 ---------------- */

label { display: block; font-size: 13px; font-weight: 700; color: var(--sub); margin: 12px 0 5px; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=password], select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 14px; font-family: inherit; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(46, 115, 196, 0.15);
}
textarea { resize: vertical; }

.row { display: flex; gap: 16px; flex-wrap: wrap; align-items: stretch; }
.row > div { flex: 1; min-width: 200px; display: flex; flex-direction: column; justify-content: flex-end; }

.item-row { display: grid; grid-template-columns: 3fr 1.5fr 1fr 0.8fr 1.2fr 1.5fr 32px; gap: 8px; align-items: end; margin-bottom: 8px; }
.items-grid-scroll .item-row { display: grid; grid-template-columns: none; gap: 0; margin: 0; padding: 0; }
.order-item-row { display: grid; gap: 0; align-items: stretch; margin: 0; padding: 0; }
.items-scroll .order-item-row { gap: 8px; margin-bottom: 8px; grid-template-columns: 2fr 2.4fr 1fr 0.8fr 1.2fr 1.2fr 2fr 32px; }
.order-item-row > div { min-width: 0; }
.order-item-row:last-child { border-bottom: none; }
.order-item-row > .remove-row { justify-self: end; }
.order-qty-toggle { cursor: pointer; color: var(--primary); font-size: 12px; font-weight: 700; margin-top: 4px; display: inline-block; }
.order-qty-toggle:hover { text-decoration: underline; }
.order-qty-breakdown { display: none; grid-column: 1 / -1; margin-top: 6px; padding: 8px 10px; background: var(--primary-pale); border-radius: 6px; border: 1px solid var(--line); }
.order-qty-breakdown.show { display: block; }
.order-qty-breakdown table { width: 100%; font-size: 12px; margin-bottom: 6px; }
.order-qty-breakdown th { background: transparent; color: var(--primary); text-transform: none; font-size: 11px; padding: 4px 6px; text-align: left; }
.order-qty-breakdown td { padding: 4px 6px; border: none; }
.order-qty-breakdown td input { padding: 5px 6px; font-size: 12px; }
.order-qty-breakdown .btn-add-sub { font-size: 11px; padding: 3px 8px; }
.order-qty-breakdown .btn-remove-sub { background: none; border: none; color: var(--red); font-size: 14px; cursor: pointer; padding: 4px; }
.items-scroll { width: 100%; overflow: visible; padding-bottom: 0; }
.items-scroll .order-item-row input[type="number"]::-webkit-inner-spin-button,
.items-scroll .order-item-row input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.items-scroll .order-item-row input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}
#itemsWrap { overflow: visible; padding-bottom: 0; }
.item-row .lbl { font-size: 11px; font-weight: 700; color: var(--sub); margin-bottom: 3px; }
.remove-row { background: none; border: none; color: var(--red); font-size: 18px; cursor: pointer; padding: 6px; }

.totals { margin-top: 16px; width: 320px; margin-left: auto; }
.totals table td { border: none; padding: 5px 4px; }
.totals .grand { font-weight: 700; color: var(--primary); font-size: 16px; border-top: 2px solid var(--primary); }

/* ---------------- 상태 필터 탭 ---------------- */

.filter-tabs { margin-bottom: 16px; }
.filter-tabs a {
  display: inline-block; padding: 7px 16px; border-radius: 20px; font-size: 13px;
  font-weight: 700;
  text-decoration: none; color: var(--sub); border: 1px solid var(--line); margin-right: 8px;
}
.filter-tabs a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------------- 로그인 ---------------- */

.login-wrap {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #123f78;
  overflow: hidden;
  z-index: 10;
}
.login-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(3,24,58,.62) 0%, rgba(2,18,44,.36) 55%, rgba(1,46,102,.50) 100%);
  z-index: 0;
  pointer-events: none;
}
.login-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 42%, rgba(0,0,0,0) 30%, rgba(0,12,32,.40) 100%);
  z-index: 1;
  pointer-events: none;
}
.login-card {
  position: relative; z-index: 2;
  width: 360px; text-align: center; padding: 36px 32px 28px;
  border: none; box-shadow: 0 12px 40px rgba(1, 46, 102, 0.35);
}
.login-card .login-logo { margin-bottom: 14px; }
.login-card .login-logo img { height: 34px; }
.login-card .logo { font-size: 15px; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.login-card .sub { font-size: 12px; color: var(--sub); margin-bottom: 22px; }
.dept-card {
  position: relative;
  z-index: 2;
  width: min(660px, calc(100vw - 32px));
  text-align: center;
  padding: 36px 34px 32px;
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 18px;
  background: rgba(255,255,255,.48);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  box-shadow: 0 26px 70px rgba(0, 10, 30, .55), 0 2px 0 rgba(255,255,255,.6) inset;
}
.dept-card .login-logo { margin-bottom: 12px; }
.dept-card .login-logo img { height: 42px; }
.dept-card .logo { font-size: 17px; font-weight: 700; color: var(--primary); margin-bottom: 20px; letter-spacing: .5px; }
.dept-title {
  font-size: 18px; font-weight: 700; margin: 0 0 20px;
  color: var(--primary-deep);
  display: inline-block;
  padding-bottom: 8px;
  border-bottom: 2px solid rgba(1,46,102,.16);
}
.dept-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.dept-grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dept-grid-5 .dept-item:nth-child(4) { grid-column: 1 / 2; }
.dept-grid-5 .dept-item:nth-child(5) { grid-column: 2 / 3; }
.dept-grid-5 .dept-item:nth-child(6) { grid-column: 3 / 4; }
.dept-grid-5 .dept-item:nth-child(7) { grid-column: 2 / 3; }
.dept-item {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  min-height: 132px; padding: 18px 12px;
  border: 1px solid rgba(1,46,102,.14);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,.58) 0%, rgba(244,248,253,.44) 100%);
  color: var(--text); text-decoration: none;
  box-shadow: 0 2px 6px rgba(1,46,102,.07);
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.dept-item:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  background: linear-gradient(180deg, rgba(255,255,255,.96) 0%, rgba(233,242,252,.9) 100%);
  box-shadow: 0 12px 26px rgba(1, 46, 102, .26);
}
.dept-item:active { transform: translateY(-1px); }
.dept-icon {
  font-size: 27px; line-height: 1; margin-bottom: 4px;
  width: 50px; height: 50px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #FFFFFF;
  border: 1px solid rgba(1,46,102,.13);
  box-shadow: 0 3px 8px rgba(1,46,102,.10);
}
.dept-name { color: var(--primary); font-size: 15px; font-weight: 700; }
.dept-desc { color: var(--sub); font-size: 11px; line-height: 1.35; }
.dept-badge { display: inline-flex; align-items: center; gap: 6px; color: var(--primary); background: #F2F7FD; border: 1px solid var(--line); border-radius: 15px; padding: 6px 12px; font-size: 13px; font-weight: 700; margin: 4px 0 20px; }
.dept-badge-icon { font-size: 16px; }
.back-to-dept { display: inline-block; margin-top: 16px; color: var(--sub); font-size: 12px; text-decoration: none; }
.back-to-dept:hover { color: var(--primary); text-decoration: underline; }
@media (max-width: 520px) { .dept-card { padding: 26px 18px; } .dept-grid, .dept-grid-5 { grid-template-columns: 1fr; } .dept-grid-5 .dept-item:nth-child(4), .dept-grid-5 .dept-item:nth-child(5), .dept-grid-5 .dept-item:nth-child(6) { grid-column: auto; } }
.error-msg { color: var(--red); font-size: 13px; margin-top: 10px; }

.order-item-row > div:nth-child(5) input[readonly] { background: #F4F7FB !important; color: var(--sub); cursor: text; }
.size-panel { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #FAFBFD; align-self: stretch; min-width: 0; }
.size-panel-title { color: var(--primary); font-size: 13px; font-weight: 700; margin-bottom: 7px; }
.size-buttons { display: flex; flex-wrap: wrap; gap: 5px; }
.size-choice { border: 1px solid var(--primary-light); border-radius: 5px; background: #fff; color: var(--primary); font-family: inherit; font-size: 12px; font-weight: 700; padding: 5px 9px; cursor: pointer; }
.size-choice:hover, .size-choice:focus { background: var(--primary); color: #fff; }
.size-custom-row { display: flex; gap: 6px; margin-top: 8px; }
.size-custom-row input { flex: 1; min-width: 0; }
.size-entries { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.size-entry { display: flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 5px; background: #fff; padding: 3px 4px 3px 7px; }
.size-entry-name { color: var(--primary); font-size: 12px; font-weight: 700; min-width: 27px; }
.size-entry-qty { width: 74px !important; padding: 5px 6px !important; }
.size-entry-remove { border: none; background: transparent; color: var(--red); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px; }
@media (max-width: 900px) { .size-panel { min-width: 100% !important; } }

/* Baris Mata Uang + Item + panel Size: kolom teks rata atas agar tidak
   "tenggelam" ke bawah saat panel Size memanjang */
.po-currency-row { align-items: flex-start; }
.po-currency-row .size-panel { margin-top: 10px; }
.po-currency-row > div:not(.size-panel) {
  flex: 0 0 300px;
  max-width: 300px;
  justify-content: flex-start;
}
.po-currency-row > div:not(.size-panel) select { margin-top: 0; }
.po-currency-row .size-panel { flex: 1 1 240px; min-width: 240px; }
@media (max-width: 900px) {
  .po-currency-row { flex-wrap: wrap; }
  .po-currency-row > div:not(.size-panel) { flex: 1 1 200px; max-width: none; }
}

.order-summary-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  margin-top: 22px;
}
.order-summary-fields > div {
  min-width: 0;
}
.order-summary-fields > div:nth-child(1) { grid-column: 1; }
.order-summary-fields > div:nth-child(2) { grid-column: 2; }
.order-summary-fields > .size-panel { grid-column: 3; grid-row: 1; }
.order-summary-fields label { margin-top: 0; }
.order-summary-fields input,
.order-summary-fields select { min-width: 0; }
@media (max-width: 900px) {
  .order-summary-fields { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .order-summary-fields .size-panel { grid-column: 1 / -1; grid-row: auto; }
}
@media (max-width: 560px) {
  .order-summary-fields { grid-template-columns: 1fr; }
  .order-summary-fields .size-panel { grid-column: auto; }
}

/* === Panel detail PO (BUYER / STYLE# / ORDER QTY + SHIP FROM / SEWING INPUT / GMT DELIVERY) === */
.po-detail-panel {
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}
.po-detail-table { width: 100%; border-collapse: collapse; }
.po-detail-table th.po-detail-label,
.po-detail-table td.po-detail-value {
  border: 1px solid var(--line);
  padding: 0;
  vertical-align: middle;
}
.po-detail-table th.po-detail-label {
  width: 130px;
  background: #DCE9F7;
  color: var(--ink);
  font-family: 'SCDream', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: left;
  padding: 10px 12px;
  white-space: nowrap;
}
.po-detail-table td.po-detail-value input {
  width: 100%;
  border: none;
  border-radius: 0;
  padding: 9px 12px;
  font-size: 13px;
  background: #fff;
}
.po-detail-table td.po-detail-value input:focus { box-shadow: none; background: #F4F8FD; }
.po-detail-table td.po-detail-value input[readonly] { background: #F7FAFD; color: var(--ink); }

/* === Rincian barang order: satu grid dinamis untuk header dan baris === */
.items-grid-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 32px 2px 0;
}
.items-grid-scroll > .item-header-row,
.items-grid-scroll > #itemsWrap {
  box-sizing: border-box;
  width: max-content;
  min-width: 0;
}
.items-grid-scroll > #itemsWrap {
  overflow: visible;
  margin: 0 !important;
  padding: 0 !important;
}

/* Header: semua kolom setinggi dua baris Size */
.items-grid-scroll > .item-header-row {
  min-height: 58px;
  margin: 0 !important;
  padding: 0 !important;
  border: 1px solid var(--primary-light);
  border-bottom: 2px solid var(--primary);
}
.items-grid-scroll > .item-header-row > div {
  min-width: 0;
  height: 57px;
  min-height: 57px;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  border-left: none !important;
  border-right: 1px solid var(--primary-light) !important;
  background: #F0F5FB;
}
.items-grid-scroll > .item-header-row > div:last-child {
  border-right: 1px solid var(--primary-light) !important;
}
.items-grid-scroll > .item-header-row .lbl {
  width: 100%;
  height: 57px;
  min-height: 57px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  margin: 0;
  background: #F0F5FB;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
}

/* Size header: label di atas, sub-judul ukuran di bawah */
.items-grid-scroll .size-group-header {
  height: 57px;
  min-height: 57px;
  display: flex !important;
  flex-direction: column;
  padding: 0 !important;
}
.items-grid-scroll .size-group-header > .lbl {
  flex: 0 0 29px;
  height: 29px;
  min-height: 29px;
  border-bottom: 1px solid var(--primary-light);
}
.items-grid-scroll .size-subheaders {
  display: grid;
  flex: 1 1 auto;
  width: 100%;
  min-height: 28px;
}
.items-grid-scroll .size-subheader {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--primary-light);
  background: #fff;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
}
.items-grid-scroll .size-subheader:last-child { border-right: 1px solid var(--primary-light) !important; }
.items-grid-scroll .size-empty-label {
  grid-column: 1 / -1;
  padding: 2px 4px 8px;
  line-height: 1.1;
  color: var(--sub);
  font-size: 10px;
  text-align: center;
}

/* Data rows: grid-template-columns selalu diberikan oleh updateGridColumns() */
.items-grid-scroll #itemsWrap > .item-row.order-item-row {
  box-sizing: border-box;
  width: max-content;
  min-width: 0;
  max-width: none;
  min-height: 44px;
  height: auto;
  max-height: none;
  margin: 0 !important;
  margin-right: 32px !important;
  padding: 0 !important;
  position: relative;
  display: grid;
  gap: 0;
  align-items: stretch;
  border-left: 1px solid var(--primary-light);
  border-right: 1px solid var(--primary-light);
  border-bottom: 1px solid var(--primary-light);
}
.items-grid-scroll #itemsWrap > .item-row.order-item-row + .item-row.order-item-row {
  border-top: 1px solid var(--primary-light) !important;
}
.items-grid-scroll #itemsWrap > .item-row.order-item-row:last-child {
  border-bottom: 2px solid var(--primary) !important;
}
.items-grid-scroll #itemsWrap > .item-row.order-item-row > div {
  min-width: 0;
  width: auto;
  height: 43px;
  min-height: 43px;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  border-left: none !important;
  border-right: 1px solid var(--primary-light) !important;
}
.items-grid-scroll #itemsWrap > .item-row.order-item-row > div:last-of-type {
  border-right: 1px solid var(--primary-light) !important;
}
.items-grid-scroll #itemsWrap > .item-row.order-item-row input,
.items-grid-scroll #itemsWrap > .item-row.order-item-row select {
  box-sizing: border-box;
  width: 100%;
  height: 43px;
  min-height: 43px;
  margin: 0;
  padding: 6px 8px;
  border: none;
  border-radius: 0;
  text-align: center;
  background: #fff !important;
}
.items-grid-scroll #itemsWrap > .item-row.order-item-row > div:last-of-type input { padding-right: 34px; }
.items-grid-scroll #itemsWrap > .item-row.order-item-row input:focus,
.items-grid-scroll #itemsWrap > .item-row.order-item-row select:focus {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  box-shadow: none;
}
.items-grid-scroll #itemsWrap > .item-row.order-item-row > .col-price input,
.items-grid-scroll #itemsWrap > .item-row.order-item-row > .col-amount .amount-value {
  text-align: right;
  padding-right: 8px;
}
.items-grid-scroll #itemsWrap > .item-row.order-item-row > .col-amount .amount-value,
.items-grid-scroll #itemsWrap > .item-row.order-item-row > .col-amount .total-value {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  height: 100%;
  padding-right: 16px;
  box-sizing: border-box;
}
.items-grid-scroll #itemsWrap > .item-row.order-item-row > .size-group {
  display: grid !important;
  min-width: 0;
  padding: 0 !important;
}
.items-grid-scroll .size-group .size-cell-input {
  width: 100%;
  min-width: 0;
  height: 43px;
  min-height: 43px;
  padding: 6px 4px !important;
  text-align: center;
  border: none !important;
  border-right: 1px solid var(--primary-light) !important;
  border-radius: 0;
}
.items-grid-scroll .size-group .size-cell-input:last-child { border-right: 1px solid var(--primary-light) !important; }

/* Tombol X hanya untuk baris kedua dan seterusnya */
.items-grid-scroll #itemsWrap > .item-row.order-item-row > .remove-row {
  position: absolute;
  z-index: 2;
  top: 0;
  right: -30px;
  width: 28px;
  height: 43px;
  min-height: 43px;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none !important;
  background: transparent;
  color: var(--red);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.items-grid-scroll #itemsWrap > .item-row.order-item-row:first-child > .remove-row {
  display: none !important;
  visibility: hidden !important;
  width: 0 !important;
  height: 0 !important;
  min-height: 0 !important;
  pointer-events: none !important;
}
.items-grid-scroll #itemsWrap > .item-row.order-item-row > .remove-row:hover { background: var(--red-pale); }
.items-grid-scroll #itemsWrap input.field-disabled,
.items-grid-scroll #itemsWrap input.field-disabled:disabled {
  background: #ECEFF4 !important;
  color: var(--sub);
  cursor: not-allowed;
}
/* Total row */
.items-grid-scroll #itemsWrap > .item-row.order-item-row.total-row {
  border-top: 2px solid var(--primary) !important;
  border-bottom: 2px solid var(--primary) !important;
  background: #F0F5FB;
}
.total-label, .total-value {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
}
.total-size-group { display: grid !important; }
.total-size-value {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  border-right: 1px solid var(--primary-light) !important;
}
.total-size-value:last-child { border-right: none !important; }
.items-grid-scroll #itemsWrap > .item-row.order-item-row input[type="number"]::-webkit-inner-spin-button,
.items-grid-scroll #itemsWrap > .item-row.order-item-row input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.items-grid-scroll #itemsWrap > .item-row.order-item-row input[type="number"] {
  -moz-appearance: textfield;
}
.items-grid-scroll + .btn { margin-top: 10px; }
#itemsWrap::-webkit-scrollbar { height: 8px; }
#itemsWrap::-webkit-scrollbar-thumb { background: #B8C7DA; border-radius: 4px; }
#itemsWrap::-webkit-scrollbar-track { background: #EEF3F8; }
.log-item { font-size: 12px; color: var(--sub); padding: 6px 0; border-bottom: 1px dashed var(--line); }
.log-item b { color: var(--ink); }
.actions-bar { display: flex; gap: 10px; margin-top: 18px; }

/* === Panel Artwork PO === */
.po-artwork-panel { margin-top: 24px; }
.po-artwork-panel h2 { margin-bottom: 10px; }
.po-artwork-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1.6fr 1.2fr;
  gap: 0;
  border: 1px solid var(--primary-light);
  border-radius: 6px;
  overflow: visible;
  background: #fff;
}
.artwork-cell { border-right: 1px solid var(--primary-light); padding: 0; min-width: 0; }
.artwork-header-grid { border-bottom: none; border-radius: 6px 6px 0 0; }
.artwork-header-grid .artwork-cell { height: 40px; }
.artwork-row { position: relative; border-top: none; border-radius: 0; }
.artwork-row + .artwork-row { border-top: 1px solid var(--primary-light); }
.artwork-row .artwork-cell { min-height: 190px; }
.artwork-row > .artwork-remove-row {
  position: absolute;
  z-index: 5;
  top: 0;
  right: -30px;
  width: 28px;
  height: 43px;
  min-height: 43px;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none !important;
  background: transparent;
  color: var(--red);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.artwork-row > .artwork-remove-row[hidden] { display: none !important; }
.artwork-row > .artwork-remove-row:hover { background: var(--red-pale); }
#artworkRows + .btn { margin-top: 10px; margin-left: 0; }
.artwork-heading {
  width: 100%;
  min-height: 40px;
  height: 40px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: #F0F5FB;
  border: 1px solid var(--primary-light);
  border-bottom: 2px solid var(--primary);
  border-radius: 0;
  padding: 0 8px;
  margin-bottom: 8px;
}
.artwork-subheading { margin-top: 10px; }
.artwork-split-heading {
  flex-direction: column;
  padding: 0;
  margin-bottom: 8px;
}
.artwork-split-heading .artwork-split-top,
.artwork-split-heading .artwork-split-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 20px;
  height: 20px;
  flex: 1 1 auto;
}
.artwork-split-heading .artwork-split-top {
  border-bottom: 1px solid var(--primary);
}
.artwork-image-cell { display: flex; flex-direction: column; gap: 8px; }
.artwork-image-inputs {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 0 8px;
}
.artwork-image-inputs input[type="file"] { width: 100%; }
.artwork-image-inputs .btn { align-self: flex-start; }
.artwork-image-cell > input[type="file"] { width: calc(100% - 16px); margin-left: 8px; }
.artwork-cell > textarea { width: calc(100% - 16px); margin-left: 8px; margin-right: 8px; }
.artwork-preview-wrap {
  position: relative;
  width: calc(100% - 16px);
  margin-left: 8px;
  margin-right: 8px;
  text-align: center;
}
.artwork-preview {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}
.artwork-image-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--red);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--red);
  font-size: 18px;
  font-weight: 700;
  line-height: 20px;
  cursor: pointer;
}
.artwork-image-remove:hover { background: var(--red-pale); }
.artwork-image-cell input[type="file"] { width: calc(100% - 16px); }
.artwork-cell textarea { width: calc(100% - 16px); min-height: 90px; resize: vertical; margin-left: 8px; margin-right: 8px; }
.artwork-printing-cell textarea { min-height: 70px; }
@media (max-width: 900px) {
  .po-artwork-grid { grid-template-columns: 1fr; }
  .artwork-cell { border-right: none; border-bottom: 1px solid var(--primary-light); }
  .artwork-cell:last-child { border-bottom: none; }
}

/* === Paling akhir: baris pertama tidak perlu tombol X === */
#itemsWrap > .item-row.order-item-row:first-child > .remove-row,
.items-grid-scroll #itemsWrap > .item-row.order-item-row:first-child > .remove-row {
  display: none !important;
  visibility: hidden !important;
  width: 0 !important;
  height: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
}