/* ============================================================================
   CBD Garment Costing — design system
   Style: High-Tech SaaS boutique · navy + electric blue · Plus Jakarta Sans
   ============================================================================ */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* brand */
  --navy:       #0F172A;
  --navy-2:     #1E293B;
  --accent:     #0369A1;
  --accent-2:   #0EA5E9;
  --grad:       linear-gradient(135deg, #0052FF 0%, #4D7CFF 100%);
  --grad-hover: linear-gradient(135deg, #0047DB 0%, #3D6CF0 100%);

  /* surfaces */
  --bg:         #F8FAFC;
  --surface:    #FFFFFF;
  --surface-2:  #F1F5F9;
  --ink:        #020617;
  --ink-soft:   #334155;
  --muted-ink:  #64748B;
  --line:       #E2E8F0;
  --muted:      #E8ECF1;

  /* semantic */
  --danger:     #DC2626;
  --danger-bg:  #FEF2F2;
  --warn-bg:    #FFFBEB;
  --warn-ink:   #92560A;
  --ok:         #059669;
  --ok-bg:      #ECFDF5;

  --radius:     16px;
  --radius-sm:  10px;
  --ring:       0 0 0 3px rgba(13, 110, 253, .25);
  --shadow-sm:  0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05);
  --shadow-md:  0 4px 12px rgba(15,23,42,.06), 0 12px 28px rgba(15,23,42,.07);
  --shadow-lg:  0 18px 50px rgba(15,23,42,.14);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  line-height: 1.55;
  background-color: var(--bg);
  /* subtle light mesh for depth */
  background-image:
    radial-gradient(900px 500px at 100% -8%, rgba(77,124,255,.10), transparent 60%),
    radial-gradient(700px 500px at -10% 0%, rgba(14,165,233,.08), transparent 55%);
  background-attachment: fixed;
  min-height: 100dvh;
}

/* ----------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 24px;
  background: rgba(255,255,255,.72);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(226,232,240,.9);
}
.brand { display: flex; align-items: center; gap: 13px; }
.logo {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  background: var(--grad); color: #fff; font-weight: 800; font-size: .95rem;
  letter-spacing: .5px; box-shadow: 0 6px 16px rgba(13,82,255,.35);
}
.brand h1 { margin: 0; font-size: 1.08rem; font-weight: 800; letter-spacing: -.01em; }
.brand p  { margin: 0; color: var(--muted-ink); font-size: .8rem; font-weight: 500; }

.userbox { display: flex; align-items: center; gap: 8px; }
.who {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 6px 12px 6px 8px; border-radius: 999px;
  color: var(--ink-soft); font-size: .8rem; font-weight: 600; max-width: 240px;
}
.who .avatar {
  width: 24px; height: 24px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; color: #fff; font-size: .72rem; font-weight: 700;
  background: var(--grad);
}
.who .who-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ----------------------------------------------------------------- layout */
main { max-width: 760px; margin: 30px auto 60px; padding: 0 18px; display: grid; gap: 18px; }
.page-head { margin: 4px 2px 0; }
.page-head h2 { margin: 0; font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--muted-ink); font-size: .92rem; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 24px;
}
.card h2 { margin: 0 0 4px; font-size: 1.12rem; font-weight: 700; letter-spacing: -.01em; }
.card .sub { margin: 0 0 18px; color: var(--muted-ink); font-size: .86rem; }

/* ----------------------------------------------------------------- forms */
label { display: block; font-weight: 600; font-size: .82rem; margin-bottom: 7px; color: var(--ink-soft); }
input[type=text], input[type=password], input[type=number], input[type=email] {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; font-size: .95rem; background: var(--surface); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #94A3B8; }
input:hover { border-color: #CBD5E1; }
input:focus { outline: none; border-color: var(--accent-2); box-shadow: var(--ring); }
.hint { color: var(--muted-ink); font-weight: 400; font-size: .78rem; }
.req { color: var(--danger); }

button {
  font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-soft); padding: 10px 16px; border-radius: var(--radius-sm); font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px; transition: transform .12s, background .15s, box-shadow .15s, border-color .15s;
}
button:hover { background: var(--surface-2); border-color: #CBD5E1; }
button:active { transform: scale(.97); }
button:focus-visible { outline: none; box-shadow: var(--ring); }

.primary {
  width: 100%; justify-content: center; color: #fff; border: none;
  background: var(--grad); box-shadow: 0 8px 20px rgba(13,82,255,.28); padding: 13px 18px; font-size: .98rem;
}
.primary:hover { background: var(--grad-hover); box-shadow: 0 10px 26px rgba(13,82,255,.34); }
.primary:disabled { opacity: .6; cursor: not-allowed; box-shadow: none; transform: none; }

.icon-btn { padding: 9px; border-radius: 10px; color: var(--muted-ink); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { color: var(--ink); }

button svg { width: 16px; height: 16px; }

/* ----------------------------------------------------------------- drop zone */
.drop {
  display: block; border: 2px dashed #CBD5E1; border-radius: var(--radius);
  padding: 30px 20px; text-align: center; cursor: pointer; margin-bottom: 14px;
  background: linear-gradient(180deg, rgba(241,245,249,.5), rgba(255,255,255,0));
  transition: border-color .15s, background .15s, transform .12s;
}
.drop:hover { border-color: var(--accent-2); background: #F0F9FF; }
.drop.over { border-color: var(--accent-2); background: #E0F2FE; transform: translateY(-1px); }
.drop-inner { display: grid; gap: 8px; justify-items: center; color: var(--ink-soft); }
.drop .drop-icon {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  background: #E0F2FE; color: var(--accent); margin-bottom: 2px;
}
.drop .drop-icon svg { width: 24px; height: 24px; }
.drop strong { color: var(--ink); }
.drop .accent { color: var(--accent); }
.drop code { background: var(--muted); padding: 1px 6px; border-radius: 5px; font-size: .76em; color: var(--ink-soft); }

.files { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 7px; }
.files li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 10px 9px 12px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-size: .86rem; animation: fadeInUp .25s ease both;
}
.files .fname { display: inline-flex; align-items: center; gap: 9px; overflow: hidden; }
.files .fname span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .tag { font-size: .66rem; font-weight: 700; letter-spacing: .03em; color: #fff;
              background: var(--muted-ink); border-radius: 5px; padding: 2px 7px; flex: 0 0 auto; }
.files .tag.xls { background: var(--ok); }
.files .tag.msg { background: #C2710C; }
.files .tag.pdf { background: var(--danger); }
.files .tag.img { background: var(--accent); }
.files .rm { padding: 4px 8px; font-size: .74rem; border-radius: 7px; color: var(--muted-ink); }

/* ----------------------------------------------------------------- unit segmented control */
.units { border: none; padding: 0; margin: 0 0 18px; }
.units legend { font-weight: 600; font-size: .82rem; margin-bottom: 8px; color: var(--ink-soft); padding: 0; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
             background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 5px; }
.segmented label {
  margin: 0; text-align: center; padding: 9px 6px; border-radius: 8px; cursor: pointer;
  font-weight: 600; font-size: .9rem; color: var(--muted-ink); transition: background .15s, color .15s, box-shadow .15s;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:hover { color: var(--ink-soft); }
.segmented input:checked + span,
.segmented label:has(input:checked) { }
.segmented label.on { background: var(--surface); color: var(--navy); box-shadow: var(--shadow-sm); }
.segmented label:focus-within { box-shadow: var(--ring); }

/* ----------------------------------------------------------------- grid */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }

/* ----------------------------------------------------------------- status */
.status { display: flex; align-items: center; gap: 14px; }
.status p { margin: 0; color: var(--ink-soft); font-weight: 600; }
.spinner {
  width: 22px; height: 22px; border: 3px solid #DBE3F0; border-top-color: var(--accent-2);
  border-radius: 50%; animation: spin .8s linear infinite; flex: 0 0 auto;
}

/* ----------------------------------------------------------------- result */
.result h2 { color: var(--navy); display: flex; align-items: center; gap: 9px; }
.result h2 .ok-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--ok-bg); color: var(--ok);
                     display: grid; place-items: center; }
.result h2 .ok-dot svg { width: 14px; height: 14px; }
.warnings { margin: 14px 0 4px; display: grid; gap: 7px; }
.warnings .w { background: var(--warn-bg); border: 1px solid #FCE3A8; color: var(--warn-ink);
               padding: 9px 12px; border-radius: var(--radius-sm); font-size: .82rem;
               display: flex; gap: 8px; align-items: flex-start; }
.warnings .w svg { width: 15px; height: 15px; flex: 0 0 auto; margin-top: 2px; }

.tbl-wrap { overflow-x: auto; margin-top: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.breakdown { width: 100%; border-collapse: collapse; font-size: .86rem; min-width: 460px; }
.breakdown th, .breakdown td { text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--line); }
.breakdown thead th { background: var(--surface-2); color: var(--muted-ink); font-weight: 700;
                      font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; }
.breakdown tbody tr:last-child td { border-bottom: none; }
.breakdown tbody tr:hover { background: #F8FAFF; }
.breakdown td.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.breakdown td.offer { font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; text-align: right; }
.dl-row { margin-top: 16px; }

/* ----------------------------------------------------------------- error */
.error h2 { color: var(--danger); }
.error pre { white-space: pre-wrap; word-break: break-word; background: var(--danger-bg);
             border: 1px solid #FECACA; color: #991B1B; padding: 12px; border-radius: var(--radius-sm);
             font-size: .82rem; font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* ----------------------------------------------------------------- change-pw panel */
#pwPanel label { margin-top: 12px; }
#pwPanel #savePw { margin-top: 16px; }
#pwMsg { margin-top: 10px; }

/* ----------------------------------------------------------------- review (step 2) */
.review-head { display: flex; align-items: center; gap: 12px; margin-bottom: 2px; }
.review-head h2 { margin: 0; }
.review-head .ghost { padding: 7px 12px; }
.rev-style { margin-top: 16px; }
.rev-style h3 { margin: 0 0 8px; font-size: .95rem; font-weight: 700; color: var(--ink); }
.rev-table { width: 100%; border-collapse: collapse; font-size: .84rem; min-width: 640px; }
.rev-table thead th { background: var(--surface-2); color: var(--muted-ink); font-weight: 700;
                      font-size: .68rem; letter-spacing: .04em; text-transform: uppercase;
                      text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); }
.rev-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.rev-table td.ro { font-weight: 600; color: var(--ink-soft); white-space: nowrap; }
.rev-table input, .rev-table select {
  width: 100%; min-width: 64px; padding: 7px 8px; font-size: .85rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.rev-table input:focus, .rev-table select:focus { outline: none; border-color: var(--accent-2); box-shadow: var(--ring); }
.rev-table input.need { background: #FFFBEB; border-color: #FCD34D; }   /* Kilo: GSM/Width needed */
.rev-table input.err, .rev-table select.err { border-color: var(--danger); background: var(--danger-bg); }
.row-err { margin: 14px 0 0; padding: 10px 12px; border-radius: var(--radius-sm); font-size: .84rem;
           color: #991B1B; background: var(--danger-bg); border: 1px solid #FECACA; }
#review .primary { margin-top: 18px; }

footer { text-align: center; color: var(--muted-ink); font-size: .78rem; padding: 8px 24px 36px; }

/* ----------------------------------------------------------------- login */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 410px; box-shadow: var(--shadow-lg); border-radius: 20px;
              padding: 32px 30px; animation: fadeInUp .4s ease both; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 6px; }
.login-brand .logo { width: 54px; height: 54px; font-size: 1.05rem; border-radius: 15px; }
.login-brand h1 { margin: 0; font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; }
.center { text-align: center; }
.login-card label { margin-top: 16px; }
.field { position: relative; }
.field .field-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
                     color: #94A3B8; pointer-events: none; }
.field .field-icon svg { width: 17px; height: 17px; display: block; }
.field input { padding-left: 38px; }
.login-card .primary { margin-top: 22px; }
.login-err { margin-top: 14px; padding: 10px 12px; border-radius: var(--radius-sm); text-align: center;
             font-size: .85rem; color: #991B1B; background: var(--danger-bg); border: 1px solid #FECACA; }

/* ----------------------------------------------------------------- motion */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.stagger > * { animation: fadeInUp .45s ease both; }
.stagger > *:nth-child(1) { animation-delay: .02s; }
.stagger > *:nth-child(2) { animation-delay: .08s; }
.stagger > *:nth-child(3) { animation-delay: .14s; }
.stagger > *:nth-child(4) { animation-delay: .20s; }

.hidden { display: none !important; }

@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .brand p { display: none; }
  .who .who-text { display: none; }
  main { margin-top: 20px; }
  .card { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, .stagger > *, .login-card, .files li { animation: none !important; transition: none !important; }
  .spinner { animation: spin 1.2s linear infinite !important; }
}
