@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── Design Tokens — NPM Green, Light Theme ───────────────────── */
:root {
  /* Brand green scale */
  --g-50:   #f1f8f4;
  --g-100:  #dcefe3;
  --g-200:  #b9dfc7;
  --g-300:  #8ec9a6;
  --g-400:  #56ae81;
  --g-500:  #2f9467;
  --g-600:  #0a6b4f;   /* primary — matches logo */
  --g-700:  #0a5a43;
  --g-800:  #073729;
  --g-900:  #041e16;

  /* Neutrals (very slightly green-tinted for warmth) */
  --ink-900: #0b1f19;
  --ink-700: #27403a;
  --ink-500: #5a6a66;
  --ink-400: #8a9894;
  --ink-300: #b7c1bd;
  --ink-200: #dde3df;
  --ink-100: #eef1ee;
  --ink-50:  #f6f8f6;
  --white:   #ffffff;
  --bg:      #f5f8f6;   /* page background — soft off-white with green undertone */
  --bg-card: #ffffff;

  /* Feedback */
  --success:     #0a6b4f;
  --success-bg:  #dcefe3;
  --warning:     #b45309;
  --warning-bg:  #fef3c7;
  --danger:      #b91c1c;
  --danger-bg:   #fee2e2;
  --info:        #0a5a43;
  --info-bg:     #dcefe3;

  /* Legacy aliases (kept so existing pages don't break) */
  --navy-dark:   var(--ink-900);
  --navy:        var(--g-700);
  --navy-mid:    var(--g-600);
  --gold:        var(--g-600);
  --gold-light:  var(--g-500);
  --off-white:   var(--ink-50);
  --gray-50:     var(--ink-50);
  --gray-100:    var(--ink-100);
  --gray-200:    var(--ink-200);
  --gray-300:    var(--ink-300);
  --gray-400:    var(--ink-400);
  --gray-500:    var(--ink-500);
  --gray-700:    var(--ink-700);
  --gray-900:    var(--ink-900);

  --font-sans:  'Manrope', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-serif: 'Manrope', -apple-system, sans-serif;  /* alias — no serif in new theme */
  --font-mono:  'JetBrains Mono', ui-monospace, monospace;

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --shadow-xs: 0 1px 2px rgba(10, 107, 79, 0.05);
  --shadow-sm: 0 2px 6px -2px rgba(10, 107, 79, 0.08);
  --shadow:    0 4px 14px -4px rgba(10, 107, 79, 0.12), 0 1px 2px rgba(10, 107, 79, 0.04);
  --shadow-md: 0 10px 28px -8px rgba(10, 107, 79, 0.18), 0 3px 6px -3px rgba(10, 107, 79, 0.06);
  --shadow-lg: 0 22px 50px -16px rgba(10, 107, 79, 0.25), 0 8px 16px -8px rgba(10, 107, 79, 0.1);

  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --ease-liquid: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ─── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: var(--font-sans);
  font-weight: 400;
  letter-spacing: -0.005em;
  color: var(--ink-900);
  background: var(--bg);
  line-height: 1.55;
  min-height: 100vh;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--g-600); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--g-700); }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3, h4, h5 { letter-spacing: -0.015em; font-weight: 600; color: var(--ink-900); }

/* Ambient page accent — soft green gradient behind content */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1000px 600px at 85% -10%, rgba(10,107,79,0.07), transparent 60%),
    radial-gradient(800px 500px at -5% 110%, rgba(47,148,103,0.06), transparent 60%);
}
.app, .main, .sidebar, .topbar, .card, .stat-card, .table-wrap, .modal, .page-loader { position: relative; z-index: 1; }

/* ─── Layout ────────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--white);
  color: var(--ink-700);
  padding: 22px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--ink-100);
}
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 22px 22px;
  border-bottom: 1px solid var(--ink-100);
  margin-bottom: 14px;
}
.sidebar__logo-mark {
  width: 34px;
  height: auto;
  color: var(--g-600);
  flex-shrink: 0;
}
.sidebar__brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.sidebar__logo {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink-900);
  letter-spacing: -0.01em;
}
.sidebar__tagline {
  font-size: 0.64rem;
  color: var(--ink-400);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 4px;
}
.sidebar__nav {
  flex: 1;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar__nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  font-size: 0.88rem;
  color: var(--ink-500);
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
  font-weight: 500;
}
.sidebar__nav a:hover { background: var(--ink-50); color: var(--ink-900); }
.sidebar__nav a.active {
  background: var(--g-50);
  color: var(--g-700);
  font-weight: 600;
}
.sidebar__nav a.active svg { color: var(--g-600); }
.sidebar__nav a svg { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 1.8; color: var(--ink-400); transition: color var(--transition); }
.sidebar__nav a:hover svg { color: var(--ink-700); }

.sidebar__section-label {
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--ink-400);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 22px 12px 8px;
}
.sidebar__user {
  margin: 14px 12px 0;
  padding: 14px;
  background: var(--ink-50);
  border-radius: var(--radius);
  border: 1px solid var(--ink-100);
}
.sidebar__user-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sidebar__role-pill {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--g-100);
  color: var(--g-800);
  border: 1px solid var(--g-200);
}
.sidebar__user-email {
  font-size: 0.72rem;
  color: var(--ink-400);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar__logout {
  display: block;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--ink-200);
  font-size: 0.78rem;
  color: var(--ink-500);
  font-weight: 500;
  background: none;
  border-left: none;
  border-right: none;
  border-bottom: none;
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: color var(--transition);
}
.sidebar__logout:hover { color: var(--g-600); }

.main {
  min-width: 0;
  padding: 32px 40px 64px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 20px;
}
.topbar__title {
  font-family: var(--font-sans);
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--ink-900);
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.topbar__subtitle {
  font-size: 0.88rem;
  color: var(--ink-500);
  margin-top: 5px;
  font-weight: 400;
}
.topbar__actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ─── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: -0.003em;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: all 0.22s var(--ease-liquid);
  white-space: nowrap;
  line-height: 1.2;
  font-family: inherit;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--g-600);
  color: var(--white);
  box-shadow: 0 1px 0 rgba(255,255,255,0.2) inset, var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) {
  background: var(--g-700);
  transform: translateY(-1px);
  box-shadow: 0 1px 0 rgba(255,255,255,0.2) inset, var(--shadow-md);
}

/* Gold alias — now the green brand button */
.btn-gold {
  background: var(--g-600);
  color: var(--white);
  font-weight: 600;
  box-shadow: 0 1px 0 rgba(255,255,255,0.2) inset, var(--shadow-sm);
}
.btn-gold:hover:not(:disabled) {
  background: var(--g-700);
  transform: translateY(-1px);
  box-shadow: 0 1px 0 rgba(255,255,255,0.2) inset, var(--shadow-md);
}

.btn-outline {
  background: var(--white);
  color: var(--ink-700);
  border-color: var(--ink-200);
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--g-300);
  background: var(--g-50);
  color: var(--g-700);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-500);
}
.btn-ghost:hover:not(:disabled) { background: var(--ink-50); color: var(--ink-900); }

.btn-danger {
  background: var(--danger);
  color: var(--white);
}
.btn-danger:hover:not(:disabled) { background: #991b1b; }

.btn-sm { padding: 7px 12px; font-size: 0.8rem; }
.btn-lg { padding: 13px 24px; font-size: 0.95rem; border-radius: var(--radius); }

.btn svg { width: 16px; height: 16px; stroke-width: 1.8; }

/* ─── Cards ──────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--ink-100);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.card--padded { padding: 24px; }

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--ink-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink-900);
  letter-spacing: -0.01em;
}
.card-body { padding: 24px; }

/* ─── Stat Cards ─────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--ink-100);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card__label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}
.stat-card__value {
  font-family: var(--font-sans);
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink-900);
  letter-spacing: -0.025em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.stat-card__sub { font-size: 0.78rem; color: var(--ink-500); margin-top: 8px; font-weight: 500; }
.stat-card__accent {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, var(--g-500), var(--g-600));
}

/* ─── Forms ─────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.form-row > .form-group { margin-bottom: 0; }
.form-label {
  display: block;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--ink-700);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 7px;
}
.form-label--required::after { content: '*'; color: var(--danger); margin-left: 3px; }
.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 10px 13px;
  font-size: 0.92rem;
  color: var(--ink-900);
  background: var(--white);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}
.form-input:hover, .form-textarea:hover, .form-select:hover { border-color: var(--ink-300); }
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--g-500);
  box-shadow: 0 0 0 4px rgba(10,107,79,0.12);
}
.form-textarea { min-height: 88px; resize: vertical; line-height: 1.55; }
.form-help { font-size: 0.76rem; color: var(--ink-500); margin-top: 6px; }

/* ─── Tables ────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--ink-100);
  background: var(--white);
}
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 13px 18px;
  background: var(--ink-50);
  border-bottom: 1px solid var(--ink-100);
  white-space: nowrap;
}
.table td {
  padding: 15px 18px;
  font-size: 0.88rem;
  color: var(--ink-900);
  border-bottom: 1px solid var(--ink-100);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--g-50); }
.table__num { font-family: var(--font-mono); font-size: 0.82rem; font-weight: 500; color: var(--g-700); }
.table__amount { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }

/* ─── Badges ────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 999px;
  letter-spacing: 0.02em;
  text-transform: capitalize;
  border: 1px solid transparent;
}
.badge--draft     { background: var(--ink-50);    color: var(--ink-500);  border-color: var(--ink-200); }
.badge--sent      { background: var(--g-50);      color: var(--g-700);    border-color: var(--g-200); }
.badge--approved  { background: var(--g-50);      color: var(--g-700);    border-color: var(--g-200); }
.badge--paid      { background: var(--g-100);     color: var(--g-800);    border-color: var(--g-300); }
.badge--cancelled { background: var(--danger-bg); color: var(--danger);   border-color: #fca5a5; }

/* ─── Empty State ───────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 64px 24px;
  color: var(--ink-500);
}
.empty__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  color: var(--ink-300);
}
.empty__title {
  font-family: var(--font-sans);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink-900);
  margin-bottom: 8px;
  letter-spacing: -0.015em;
}
.empty__text { font-size: 0.9rem; max-width: 380px; margin: 0 auto 24px; line-height: 1.6; }

/* ─── Alerts ────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert--info    { background: var(--g-50);      color: var(--g-800);    border-color: var(--g-200); }
.alert--error   { background: var(--danger-bg); color: var(--danger);   border-color: #fca5a5; }
.alert--success { background: var(--g-100);     color: var(--g-800);    border-color: var(--g-300); }

/* ─── Modal (liquid-glass backdrop) ─────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(7, 55, 41, 0.28);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 24px;
  z-index: 100;
  overflow-y: auto;
  backdrop-filter: blur(8px) saturate(160%);
  -webkit-backdrop-filter: blur(8px) saturate(160%);
}
.modal.open { display: flex; animation: fadeIn 0.2s ease; }
.modal__panel {
  background: var(--white);
  border-radius: var(--radius-lg);
  max-width: 560px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalIn 0.28s var(--ease-liquid);
  border: 1px solid var(--ink-100);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
  from { transform: translateY(-12px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* ─── Utilities ─────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; }
.text-sm { font-size: 0.85rem; } .text-xs { font-size: 0.75rem; }
.text-muted { color: var(--ink-500); }
.text-gold { color: var(--g-600); }
.text-green { color: var(--g-600); }
.text-right { text-align: right; }
.font-mono { font-family: var(--font-mono); }
.font-serif { font-family: var(--font-sans); }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ─── Spinner ───────────────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.page-loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* ─── Skeleton shimmer ──────────────────────────────────────────── */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--ink-100);
  border-radius: 6px;
  color: transparent !important;
  user-select: none;
  pointer-events: none;
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.65) 50%,
    transparent 100%
  );
  animation: shimmer 1.4s infinite;
}
.skeleton--text   { height: 0.9em; border-radius: 4px; display: inline-block; width: 100%; }
.skeleton--line   { height: 12px; border-radius: 6px; }
.skeleton--title  { height: 28px; border-radius: 8px; width: 60%; }
.skeleton--stat   { height: 36px; border-radius: 8px; width: 70%; }
.skeleton--pill   { height: 20px; border-radius: 999px; width: 68px; display: inline-block; }
.skeleton--circle { border-radius: 50%; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* When the dashboard wrapper is in loading state, disable hover on stat cards */
.is-loading .stat-card:hover { transform: none; box-shadow: var(--shadow-xs); }

/* ─── Entity segmented picker (doc editor) ─────────────────────── */
.entity-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 8px;
  border: 1px solid var(--ink-200);
  background: var(--white);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.22s var(--ease-liquid);
  font-family: inherit;
  text-align: left;
  line-height: 1.15;
}
.entity-btn:hover { border-color: var(--g-300); background: var(--g-50); }
.entity-btn__flag {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--ink-50);
  color: var(--ink-700);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  border: 1px solid var(--ink-200);
  transition: all 0.22s var(--ease-liquid);
}
.entity-btn__body { display: flex; flex-direction: column; gap: 2px; }
.entity-btn__name { font-size: 0.84rem; font-weight: 600; color: var(--ink-900); letter-spacing: -0.005em; }
.entity-btn__meta { font-size: 0.7rem; color: var(--ink-500); font-weight: 500; font-variant-numeric: tabular-nums; }

.entity-btn--on {
  border-color: var(--g-600);
  background: var(--g-50);
  box-shadow: 0 0 0 3px rgba(10,107,79,0.12), var(--shadow-xs);
}
.entity-btn--on .entity-btn__flag {
  background: var(--g-600);
  color: #fff;
  border-color: var(--g-600);
}
.entity-btn--on .entity-btn__name { color: var(--g-800); }
.entity-btn--on .entity-btn__meta { color: var(--g-700); }

/* ─── Scrollbar polish (WebKit) ────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-300); }

/* ─── Responsive ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    width: 260px;
    z-index: 50;
    transition: left var(--transition);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { left: 0; }
  .main { padding: 24px 20px 48px; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
