/* ============================================================
   HR Wage Manager — design tokens
   Imported from the Cuupy design system (Claude Design project
   "Multi-location wage and payroll app" → _ds/cuupy-design-system/colors_and_type.css)
   Tokens are verbatim; the app chrome below is additive.
   ============================================================ */

:root {
  /* ============ CORE PALETTE ============ */
  --green:         #2D6A4F;
  --green-ink:     #1F4A37;
  --green-soft:    #E7F1EC;
  --green-border:  #BCD9C8;
  --green-soft-hi: #DCEBE2;

  --ink:           #1A1A1A;
  --ink-2:         #6B7280;
  --border:        #E5E7EB;
  --border-strong: #D1D5DB;
  --input-bg:      #F9FAFB;
  --surface-mut:   #F3F4F6;
  --white:         #FFFFFF;
  --page-bg:       #FAFAF7;

  --error:         #EF4444;
  --error-ink:     #DC2626;
  --error-soft:    #FEF2F2;
  --error-border:  #FECACA;

  --amber:         #B45309;
  --amber-ink:     #92651A;
  --amber-strong:  #D97706;
  --amber-soft:    #FEF3C7;
  --amber-border:  #FDE68A;

  /* ============ STATUS TOKENS ============ */
  --status-pending-bg:    #FEF3C7;  --status-pending-ink:    #92651A;  --status-pending-border:    #FDE68A;
  --status-confirmed-bg:  #E7F1EC;  --status-confirmed-ink:  #1F4A37;  --status-confirmed-border:  #BCD9C8;
  --status-preparing-bg:  #FEF6E0;  --status-preparing-ink:  #92651A;  --status-preparing-border:  #FCE7A2;
  --status-delivered-bg:  #E0E7FF;  --status-delivered-ink:  #3730A3;  --status-delivered-border:  #C7D2FE;
  --status-cancelled-bg:  #F3F4F6;  --status-cancelled-ink:  #6B7280;  --status-cancelled-border:  #E5E7EB;

  /* ============ TYPOGRAPHY ============ */
  --font-sans: "Noto Sans Thai", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;

  --fw-regular: 400; --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700;

  --fs-display: 30px; --fs-h1: 26px; --fs-h2: 24px; --fs-h3: 18px;
  --fs-lead: 16.5px;  --fs-body: 16px; --fs-input: 18px; --fs-ui: 15.5px;
  --fs-sm: 14px;      --fs-xs: 13px;   --fs-amount: 32px;

  --lh-tight: 1.3; --lh-body: 1.5; --lh-relaxed: 1.6;
  --ls-tight: -.01em; --ls-wide: .05em; --ls-caps: .06em;

  /* ============ RADII ============ */
  --r-xs: 2px; --r-code: 6px; --r-sm: 8px; --r-md: 10px;
  --r-lg: 12px; --r-xl: 14px; --r-2xl: 16px; --r-pill: 999px;

  /* ============ SHADOWS ============ */
  --sh-card:    0 1px 4px rgba(0,0,0,.05);
  --sh-card-sm: 0 1px 3px rgba(0,0,0,.04);
  --sh-raised:  0 1px 3px rgba(0,0,0,.04), 0 6px 24px rgba(31,74,55,.05);
  --sh-btn:     0 1px 2px rgba(45,106,79,.25);
  --sh-btn-hi:  0 4px 12px rgba(45,106,79,.35);
  --sh-modal:   0 8px 40px rgba(0,0,0,.18);
  --sh-pop:     0 8px 24px rgba(0,0,0,.18);
  --focus-ring: 0 0 0 4px rgba(45,106,79,.10);

  /* ============ SPACING ============ */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 10px; --sp-4: 12px;
  --sp-5: 14px; --sp-6: 18px; --sp-7: 22px; --sp-8: 28px;
  --sp-9: 32px; --sp-10: 36px;

  --h-control: 44px; --h-compact: 42px; --h-pill: 36px; --h-add: 40px;
}

/* ============ BASE ============ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--page-bg);
  color: var(--ink);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
input, button, select, textarea { font-family: inherit; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--green) !important; box-shadow: var(--focus-ring);
}
::selection { background: rgba(45,106,79,.18); }

h1 { font-size: var(--fs-display); font-weight: var(--fw-bold); letter-spacing: var(--ls-tight); margin: 0; }
h2 { font-size: var(--fs-h2); font-weight: var(--fw-bold); letter-spacing: var(--ls-tight); margin: 0; }
h3 { font-size: var(--fs-h3); font-weight: var(--fw-bold); letter-spacing: .01em; margin: 0; }
p  { font-size: var(--fs-body); color: var(--ink-2); line-height: var(--lh-relaxed); margin: 0; }
code, .mono { font-family: var(--font-mono); letter-spacing: var(--ls-wide); }

.eyebrow {
  font-size: var(--fs-sm); font-weight: var(--fw-medium); letter-spacing: var(--ls-caps);
  text-transform: uppercase; color: var(--ink-2);
}
.num { font-variant-numeric: tabular-nums; }

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

/* ============ MOTION ============ */
@keyframes fadein { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop    { from { opacity: 0; transform: scale(.94); }       to { opacity: 1; transform: none; } }
.fade { animation: fadein .22s ease both; }
.pop  { animation: pop .2s cubic-bezier(.34,1.2,.64,1) both; }

/* ============ APP CHROME ============ */
.hoverrow:hover { background: var(--surface-mut); }
.gridcell:focus { position: relative; z-index: 2; }

.btn {
  height: var(--h-control); padding: 0 20px; border: none; border-radius: var(--r-sm);
  background: var(--green); color: #fff; font-size: var(--fs-ui); font-weight: 600;
  box-shadow: var(--sh-btn); cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .1s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:not([disabled]):hover { background: var(--green-ink); box-shadow: var(--sh-btn-hi); transform: scale(1.015); }
.btn:not([disabled]):active { transform: scale(.96); box-shadow: none; }
.btn[disabled] { background: var(--border-strong); cursor: not-allowed; box-shadow: none; }

.btn-ghost {
  height: var(--h-control); padding: 0 18px; border: 1.5px solid var(--border-strong);
  border-radius: var(--r-sm); background: var(--white); color: var(--ink-2);
  font-size: var(--fs-ui); font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-ghost:not([disabled]):hover { background: var(--surface-mut); }
.btn-ghost[disabled] { opacity: .55; cursor: not-allowed; }

.btn-dash {
  height: var(--h-add); padding: 0 16px; border: 1.5px dashed var(--green-border);
  border-radius: var(--r-sm); background: var(--green-soft); color: var(--green-ink);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-dash:hover { background: var(--green-soft-hi); }

.btn-danger {
  height: var(--h-control); padding: 0 18px; border: 1.5px solid var(--error-border);
  border-radius: var(--r-sm); background: var(--error-soft); color: var(--error-ink);
  font-size: var(--fs-ui); font-weight: 600; cursor: pointer;
}
.btn-danger:hover { background: #FDE2E2; }

.field {
  height: var(--h-control); padding: 0 13px; font-size: var(--fs-input);
  border: 1.5px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--input-bg); width: 100%;
}
.field-sm { height: var(--h-compact); font-size: var(--fs-ui); }

.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-card);
}

.iconbtn {
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--r-sm); background: transparent; color: var(--ink-2); cursor: pointer;
}
.iconbtn:hover { background: var(--error-soft); color: var(--error-ink); }

/* ============ RESPONSIVE: phone-first shift entry, desktop payroll ============ */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex: none; background: var(--white); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.main { flex: 1; min-width: 0; padding: 30px 36px 60px; }

.mobilebar { display: none; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { display: none; }
  .main { padding: 16px 14px 90px; }
  .mobilebar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--white); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mobilebar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    border: none; background: transparent; cursor: pointer; padding: 6px 2px;
    font-size: 10.5px; font-weight: 600;
  }
  .desktop-only { display: none !important; }
}

@media (min-width: 861px) {
  .phone-only { display: none !important; }
}

/* wide content scrolls inside its own container, never the page body */
.scrollx { overflow-x: auto; max-width: 100%; }

/* ---------- modal layout ----------
   Header and footer stay put; only the fields scroll. Before this the whole
   panel scrolled as one block, so on a short viewport the Save button sat below
   the fold with no way to reach it.
   The dvh line overrides the vh line in browsers that support it: on mobile
   100vh includes the strip behind the browser chrome, so 90vh can exceed what
   is actually visible. Keep both, in this order. */
.modal-wrap {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  overflow-y: auto;                 /* if the panel ever exceeds the wrap,
                                       centring alone would clip its top */
  background: rgba(0, 0, 0, .45);
}
.modal-panel {
  display: flex; flex-direction: column;
  width: 100%;
  max-height: 90vh;
  max-height: 90dvh;
}
.modal-head, .modal-foot { flex: 0 0 auto; }
.modal-body {
  flex: 1 1 auto;
  min-height: 0;                    /* without this a flex child refuses to
                                       shrink below its content height */
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (max-width: 860px) {
  .modal-wrap { padding: 10px; align-items: flex-end; }
  .modal-panel { max-height: 92dvh; }
}
