/* ================================================================
   CEO ERP — design system
   Warm, calm, high-contrast. Light + dark, driven by [data-theme].
   ================================================================ */

:root {
  /* Brand trio: green leads, blue supports, yellow highlights. Every value
     below is tuned to clear WCAG AA against the surface it sits on. */
  --accent: #2b8355;
  --accent-hover: #257049;
  --accent-strong: #226844;
  --accent-soft: #eaf4ee;
  --accent-ring: rgba(47, 143, 91, 0.28);
  --hero-from: #2c8357;
  --hero-to: #226443;

  --bg: #f5f7f6;
  --surface: #fdfdfc;
  --surface-2: #f7f9f8;
  --surface-3: #eef2f0;
  --border: #e2e8e5;
  --border-strong: #cfd8d4;

  --text: #23302b;
  --text-2: #55635d;
  --text-3: #85918c;
  --text-inverse: #ffffff;

  --green: #287b51;
  --green-soft: #eaf4ee;
  --amber: #876d0d;
  --amber-soft: #fdf6e3;
  --yellow: #e8b62c;
  --yellow-ink: #3a2e05;
  --yellow-soft: #fdf6e3;
  --red: #ba453d;
  --red-soft: #fbeeec;
  --blue: #2b6cb0;
  --blue-soft: #eaf1fa;
  --violet: #245a93;
  --violet-soft: #e7eefb;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --shadow-sm: 0 1px 2px rgba(35, 48, 43, 0.04);
  --shadow: 0 2px 8px rgba(35, 48, 43, 0.06), 0 1px 2px rgba(35, 48, 43, 0.03);
  --shadow-lg: 0 12px 32px rgba(35, 48, 43, 0.10), 0 2px 8px rgba(35, 48, 43, 0.05);

  /* A dark slab used behind product banners and footers. It is a surface, not
     a text colour, so it stays dark in both themes - only the shade shifts. */
  --slab: #1e2a2f;
  --slab-text: #ccd8dc;
  --slab-heading: #ffffff;
  --slab-muted: #94a5ab;

  --sidebar-w: 250px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

[data-theme='dark'] {
  --slab: #141d21;
  --slab-text: #d3dee2;
  --slab-heading: #ffffff;
  --slab-muted: #9fb0b6;

  --accent: #63c48c;
  --accent-hover: #7bd09e;
  --accent-strong: #93dbb0;
  --accent-soft: #16281f;
  --accent-ring: rgba(99, 196, 140, 0.26);
  --hero-from: #2c6b48;
  --hero-to: #1c4a31;

  --bg: #171a19;
  --surface: #1f2321;
  --surface-2: #252927;
  --surface-3: #2d312f;
  --border: #353a38;
  --border-strong: #474d4a;

  --text: #e2e7e4;
  --text-2: #a6afab;
  --text-3: #7d8783;
  --text-inverse: #171a19;

  --green: #63c48c;
  --green-soft: #16281f;
  --amber: #e2be5e;
  --amber-soft: #2c2617;
  --yellow: #e0b449;
  --yellow-ink: #3a2e05;
  --yellow-soft: #2c2617;
  --red: #e08279;
  --red-soft: #2f1e1c;
  --blue: #74aae8;
  --blue-soft: #16233a;
  --violet: #8fbdf2;
  --violet-soft: #17253c;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.55;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.015em; font-weight: 650; }
p { margin: 0; }

::selection { background: var(--accent-ring); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------------------------- layout ---------------------------- */

.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.between { display: flex; align-items: center; justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.gap-4 { gap: 16px; } .gap-5 { gap: 20px; } .gap-6 { gap: 24px; } .gap-8 { gap: 32px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.center { text-align: center; }
.hide { display: none !important; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

/* --------------------------- typography ------------------------- */

.t-xs { font-size: 12px; } .t-sm { font-size: 13px; } .t-md { font-size: 14px; }
.t-lg { font-size: 17px; } .t-xl { font-size: 20px; } .t-2xl { font-size: 26px; }
.t-3xl { font-size: 34px; } .t-4xl { font-size: 46px; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.bold { font-weight: 650; }
.semi { font-weight: 550; }
.mono { font-family: var(--mono); font-size: 0.9em; }
.eyebrow {
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--accent);
}
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------- surfaces -------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px; }
.card-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}

/* Cards can be folded away so a long dashboard stays scannable. The chevron
   points up while the body is showing and down once it is put away. */
.card-fold {
  border: 0; background: none; cursor: pointer; padding: 2px;
  color: var(--text-3); line-height: 0; flex-shrink: 0;
  transform: rotate(-90deg); transition: transform .18s, color .13s;
}
.card-fold:hover { color: var(--text); }
.card.folded .card-fold { transform: rotate(90deg); }
.card.folded > .card-head { border-bottom: 0; }
.card.folded > .card-pad,
.card.folded > .table-wrap,
.card.folded > .card-foot { display: none; }

.panel { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.divider { height: 1px; background: var(--border); border: 0; margin: 0; }

/* ---------------------------- buttons --------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 550; cursor: pointer;
  transition: background .15s, border-color .15s, transform .06s, opacity .15s;
  white-space: nowrap; text-align: center;
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }

.btn-danger { color: var(--red); border-color: var(--border-strong); background: var(--surface); }
.btn-danger:hover:not(:disabled) { background: var(--red-soft); border-color: var(--red); }

.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 7px; }
.btn-lg { padding: 12px 22px; font-size: 15px; border-radius: var(--radius); }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* ---------------------------- forms ----------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.label {
  font-size: 11.5px; font-weight: 650; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-3);
}
.input, .select, .textarea {
  width: 100%; padding: 10px 13px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
  font-size: 14.5px;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring);
}
.input:disabled, .select:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; }
.textarea { resize: vertical; min-height: 88px; line-height: 1.6; font-family: inherit; }
.select { appearance: none; cursor: pointer; padding-right: 34px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238a827c' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.hint { font-size: 12.5px; color: var(--text-3); line-height: 1.5; }
.field-error { font-size: 12.5px; color: var(--red); }

.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.check input[type='checkbox'] { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .input { padding-right: 42px; }
.input-affix {
  position: absolute; right: 6px; display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border: 0; background: transparent; color: var(--text-3);
  cursor: pointer; border-radius: 6px;
}
.input-affix:hover { color: var(--text); background: var(--surface-3); }

/* ---------------------------- badges ---------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: .01em;
  background: var(--surface-3); color: var(--text-2); border: 1px solid transparent;
  white-space: nowrap;
}
.badge-accent { background: var(--accent-soft); color: var(--accent-strong); }
.badge-green  { background: var(--green-soft);  color: var(--green); }
.badge-amber  { background: var(--amber-soft);  color: var(--amber); }
.badge-red    { background: var(--red-soft);    color: var(--red); }
.badge-blue   { background: var(--blue-soft);   color: var(--blue); }
.badge-violet { background: var(--violet-soft); color: var(--violet); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* ---------------------------- avatar ---------------------------- */

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  font-size: 13px; font-weight: 650; color: #fff; flex-shrink: 0;
  background: var(--accent); letter-spacing: .02em; user-select: none;
}
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 52px; height: 52px; font-size: 18px; }

/* ---------------------------- tables ---------------------------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; padding: 11px 16px;
  font-size: 11.5px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3); background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------- modal ----------------------------- */

.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 17, 15, 0.5); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
  animation: fade .15s ease;
}
.modal {
  width: 100%; max-width: 560px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
  animation: pop .18s cubic-bezier(.2,.9,.3,1.2);
  margin: auto 0;
}
.modal-wide { max-width: 760px; }
.modal-head { padding: 22px 24px 0; }
.modal-body { padding: 20px 24px; }
.modal-foot {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98) } to { opacity: 1; transform: none } }

/* ---------------------------- alerts ---------------------------- */

.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius-sm);
  font-size: 14px; line-height: 1.55; border: 1px solid transparent;
}
.alert-error { background: var(--red-soft); color: var(--red); }
.alert-ok { background: var(--green-soft); color: var(--green); }
.alert-info { background: var(--blue-soft); color: var(--blue); }
.alert-warn { background: var(--amber-soft); color: var(--amber); }

/* ---------------------------- toast ----------------------------- */

.toast-host {
  position: fixed; bottom: 20px; right: 20px; z-index: 300;
  display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 40px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 12px 14px; border-radius: var(--radius); box-shadow: var(--shadow-lg);
  font-size: 14px; animation: slide .2s ease;
}
.toast-ok { border-left-color: var(--green); }
.toast-err { border-left-color: var(--red); }
@keyframes slide { from { opacity: 0; transform: translateX(16px) } to { opacity: 1; transform: none } }

/* --------------------------- app shell -------------------------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-head { padding: 18px 18px 14px; border-bottom: 1px solid var(--border); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); }

.nav-group-label {
  font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-3); padding: 14px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 14.5px; font-weight: 500;
  transition: background .13s, color .13s; cursor: pointer; margin-bottom: 1px;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.nav-item svg { flex-shrink: 0; }
.nav-count {
  margin-left: auto; font-size: 11.5px; font-weight: 650;
  background: var(--accent); color: #fff; border-radius: 999px; padding: 1px 7px; min-width: 20px; text-align: center;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 62px; flex-shrink: 0;
  border-bottom: 1px solid var(--border); background: var(--surface);
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
  position: sticky; top: 0; z-index: 20;
}
.content { padding: 28px 24px 64px; flex: 1; }
.content-narrow { max-width: 900px; }

.page-head { margin-bottom: 24px; }
.page-title { font-size: 25px; font-weight: 680; }
.page-sub { color: var(--text-2); font-size: 14.5px; margin-top: 5px; }

/* --------------------------- grids ------------------------------ */

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px;
}
.stat-label { font-size: 12.5px; color: var(--text-3); font-weight: 550; }
.stat-value { font-size: 30px; font-weight: 680; letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-foot { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }

.tile {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
a.tile:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-2px); }
.tile-icon {
  width: 42px; height: 42px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}

/* --------------------------- misc ------------------------------- */

.empty { text-align: center; padding: 52px 24px; color: var(--text-3); }
.empty-icon {
  width: 54px; height: 54px; border-radius: 50%; background: var(--surface-3);
  display: inline-flex; align-items: center; justify-content: center; margin-bottom: 14px; color: var(--text-3);
}

.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin .65s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg) } }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px 4px 10px; border-radius: 7px; font-size: 13px;
  background: var(--surface-3); border: 1px solid var(--border);
}
.chip button { border: 0; background: none; cursor: pointer; color: var(--text-3); padding: 0 2px; line-height: 1; font-size: 15px; }
.chip button:hover { color: var(--red); }
.chip-bad { background: var(--red-soft); border-color: transparent; color: var(--red); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab {
  padding: 10px 14px; font-size: 14.5px; font-weight: 550; color: var(--text-2);
  border: 0; background: none; cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.copy-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 8px 7px 12px;
}
.copy-row code { flex: 1; font-family: var(--mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }

.progress { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }

/* --------------------------- auth pages ------------------------- */

.auth-page { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.auth-body { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.auth-card { width: 100%; max-width: 430px; }
.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-title { font-size: 30px; font-weight: 690; letter-spacing: -0.025em; }
.auth-title span { color: var(--accent); }
.auth-sub { color: var(--text-2); margin-top: 8px; font-size: 15px; }

.or-line { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; }
.or-line::before, .or-line::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.topnav {
  height: 64px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16.5px; letter-spacing: -0.02em; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 750;
}

/* --------------------------- responsive ------------------------- */

.mobile-only { display: none; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed; z-index: 60; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .mobile-only { display: inline-flex; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; }
  .content { padding: 20px 16px 56px; }
  .topbar { padding: 0 16px; }
  .table th, .table td { padding: 11px 12px; }
}

@media (max-width: 560px) {
  .hide-sm { display: none !important; }
  .page-title { font-size: 21px; }
  .stat-value { font-size: 25px; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
}

@media print {
  .sidebar, .topbar, .btn { display: none !important; }
}

/* ---- auth extras (phase 1) ---- */
.input.is-invalid { border-color: var(--red); }
.otp-input { font-size: 22px; letter-spacing: 6px; text-align: center; font-variant-numeric: tabular-nums; }
.auth-links { display: flex; justify-content: flex-end; margin-top: -6px; }
.auth-links a { font-size: 13px; color: var(--accent); }
.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text); }
.google-btn:hover { background: var(--surface-2); }
