/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:       #3B6D11;
  --green-light: #eaf3de;
  --green-mid:   #c0dd97;
  --green-dark:  #27500A;
  --border:      #e4edd9;
  --sidebar-w:   220px;
  --topbar-h:    60px;
  --font:        -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono:   "SF Mono", "Fira Code", monospace;
}

html, body { height: 100%; }
body { font-family: var(--font); background: #f5f7f2; color: #1a1a1a; font-size: 14px; line-height: 1.5; }
a { text-decoration: none; color: inherit; }
button, input, select { font-family: inherit; font-size: 13px; }

/* ── Shell layout ─────────────────────────────────────────────────────────── */
.shell { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100vh; position: fixed; left: 0; top: 0; z-index: 100;
}
.sidebar-logo {
  padding: 20px 18px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.logo-mark {
  width: 30px; height: 30px; background: var(--green); border-radius: 8px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.logo-mark svg { width: 16px; height: 16px; fill: #fff; }
.logo-text { font-size: 14px; font-weight: 600; }

.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-section {
  font-size: 10px; font-weight: 600; color: #9ca3af;
  text-transform: uppercase; letter-spacing: .08em; padding: 12px 10px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px;
  font-size: 13px; color: #6b7280; cursor: pointer;
  transition: background .15s, color .15s; margin-bottom: 2px;
}
.nav-item:hover { background: #f5f7f2; color: #1a1a1a; }
.nav-item.active { background: var(--green-light); color: var(--green); font-weight: 500; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto; background: var(--green-mid); color: var(--green-dark);
  font-size: 10px; font-weight: 600; padding: 1px 7px; border-radius: 20px;
}
.sidebar-footer { padding: 12px 10px; border-top: 1px solid var(--border); }
.user-card {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
.user-card:hover { background: #f5f7f2; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--green-mid); color: var(--green-dark);
  font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: #9ca3af; }
.logout-btn { background: none; border: none; cursor: pointer; color: #9ca3af; padding: 4px; border-radius: 5px; display: flex; align-items: center; }
.logout-btn:hover { color: #ef4444; background: #fef2f2; }

/* ── Main area ────────────────────────────────────────────────────────────── */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100vh; overflow: hidden; }

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h); background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; flex-shrink: 0;
}
.topbar-left .page-title { font-size: 15px; font-weight: 600; }
.topbar-left .breadcrumb { font-size: 11.5px; color: #9ca3af; margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.count-badge { font-size: 11px; background: var(--green-light); color: var(--green); border-radius: 20px; padding: 3px 10px; font-weight: 500; }

/* ── Page content ─────────────────────────────────────────────────────────── */
.page-content { flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }

/* ── Stat grid ────────────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; }
.stat-label { font-size: 11.5px; color: #6b7280; margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 600; }
.stat-trend { font-size: 11px; margin-top: 4px; }
.stat-trend.up { color: var(--green); }
.stat-trend.down { color: #ef4444; }

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card { background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.card-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 13px; font-weight: 600; }
.card-body { padding: 16px 18px; }

/* ── Filters ──────────────────────────────────────────────────────────────── */
.filter-bar { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-bar input, .filter-bar select {
  height: 34px; padding: 0 10px;
  border: 1px solid #d1d5db; border-radius: 7px;
  background: #fff; color: #1a1a1a; outline: none; font-size: 12.5px; transition: border-color .15s;
}
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--green); }
.btn { height: 34px; padding: 0 14px; border-radius: 7px; border: none; cursor: pointer; font-size: 12.5px; font-weight: 500; transition: opacity .15s; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { opacity: .88; }
.btn-ghost { background: transparent; border: 1px solid #d1d5db; color: #6b7280; }
.btn-ghost:hover { background: #f9fafb; }

/* ── Table ────────────────────────────────────────────────────────────────── */
.tbl-wrap { background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow-y: auto;
  overflow-x: auto;}
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
thead tr { background: #f9faf7; }
th { padding: 10px 14px; text-align: left; font-size: 10.5px; font-weight: 600; color: #6b7280; text-transform: uppercase; letter-spacing: .07em; white-space: nowrap; }
td { padding: 11px 14px; border-top: 1px solid var(--border); vertical-align: middle; }
tbody tr { cursor: pointer; transition: background .1s; }
tbody tr:hover { background: #f8faf6; }
.mono { font-family: var(--font-mono); font-size: 11.5px; color: var(--green); font-weight: 500; }
.cell-sub { font-size: 11px; color: #9ca3af; margin-top: 1px; }
.tbl-empty { padding: 40px; text-align: center; color: #9ca3af; font-size: 13px; }
.product-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: middle; }

/* ── Skeleton ─────────────────────────────────────────────────────────────── */
.skeleton { height: 14px; background: linear-gradient(90deg,#f0f0f0 25%,#e8e8e8 50%,#f0f0f0 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 4px; }
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ── Status pills ─────────────────────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.pill::before { content:""; width:5px; height:5px; border-radius:50%; flex-shrink:0; }
.pill-bound     { background:#eaf3de; color:#27500A; }
.pill-bound::before { background:#3B6D11; }
.pill-quoted    { background:#e6f1fb; color:#0c447c; }
.pill-quoted::before { background:#378add; }
.pill-open      { background:#faeeda; color:#633806; }
.pill-open::before { background:#ef9f27; }
.pill-cancelled { background:#fcebeb; color:#791f1f; }
.pill-cancelled::before { background:#e24b4a; }
.pill-closed    { background:#f3f4f6; color:#6b7280; }
.pill-closed::before { background:#9ca3af; }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pager { display: flex; align-items: center; justify-content: center; gap: 8px; }
.pager button { height: 34px; padding: 0 14px; border: 1px solid #d1d5db; border-radius: 7px; background: #fff; cursor: pointer; font-size: 12.5px; }
.pager button:hover:not(:disabled) { background: #f9fafb; }
.pager button:disabled { opacity: .4; cursor: default; }
.pager .page-info { font-size: 12.5px; color: #6b7280; min-width: 64px; text-align: center; }

/* ── Bar chart ────────────────────────────────────────────────────────────── */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.bar-lbl { width: 70px; text-align: right; color: #6b7280; flex-shrink: 0; }
.bar-track { flex: 1; height: 8px; background: #f0f4ee; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; transition: width .5s ease; }
.bar-val { width: 36px; font-weight: 500; font-size: 12px; }

/* ── Recent list ──────────────────────────────────────────────────────────── */
.recent-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.recent-item:last-child { border-bottom: none; }
.recent-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.recent-info { flex: 1; min-width: 0; }
.recent-pol { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--green); }
.recent-name { font-size: 11.5px; color: #6b7280; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-amt { font-size: 12px; font-weight: 500; text-align: right; flex-shrink: 0; }

/* ── Drawer ───────────────────────────────────────────────────────────────── */
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 200; opacity: 0; pointer-events: none; transition: opacity .25s; }
.drawer-overlay.open { opacity: 1; pointer-events: all; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh;
  width: 460px; max-width: 95vw; background: #fff;
  border-left: 1px solid var(--border); z-index: 201;
  transform: translateX(100%); transition: transform .28s ease;
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 18px 20px; border-bottom: 1px solid var(--border); background: #f9faf7; flex-shrink: 0; }
.drawer-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.drawer-product { font-size: 10.5px; color: #9ca3af; text-transform: uppercase; letter-spacing: .07em; margin-bottom: 4px; }
.drawer-policy { font-family: var(--font-mono); font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.close-btn { width: 28px; height: 28px; border: 1px solid #d1d5db; border-radius: 7px; background: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; color: #6b7280; flex-shrink: 0; }
.close-btn:hover { background: #f9fafb; color: #1a1a1a; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 20px; }
.d-section { }
.d-section-title { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--green); border-bottom: 1px solid var(--green-light); padding-bottom: 7px; margin-bottom: 12px; }
.d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.d-field { display: flex; flex-direction: column; gap: 2px; }
.d-label { font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: .07em; color: #9ca3af; }
.d-value { font-size: 12.5px; color: #1a1a1a; }
.d-value a { color: var(--green); }
.d-value a:hover { text-decoration: underline; }
.d-total { font-weight: 600; color: var(--green); font-size: 13px; }

/* ── Login ────────────────────────────────────────────────────────────────── */
.login-shell { min-height: 100vh; display: flex; }
.login-left { flex: 1; background: #0d1f06; position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 40px 48px; }
.login-left-bg { position: absolute; inset: 0; background: radial-gradient(circle at 30% 80%, rgba(59,109,17,.4) 0%, transparent 60%); pointer-events: none; }
.login-brand { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.login-brand-mark { width: 36px; height: 36px; background: var(--green); border-radius: 9px; display: flex; align-items: center; justify-content: center; }
.login-brand-mark svg { width: 18px; height: 18px; fill: #fff; }
.login-brand-name { font-size: 16px; font-weight: 600; color: #fff; }
.login-copy { position: relative; z-index: 1; }
.login-headline { font-size: 40px; font-weight: 700; color: #fff; line-height: 1.2; letter-spacing: -.5px; }
.login-headline span { color: #97c459; }
.login-sub { font-size: 15px; color: rgba(255,255,255,.55); margin-top: 14px; max-width: 340px; line-height: 1.6; }
.login-right { width: 480px; flex-shrink: 0; background: #fff; display: flex; flex-direction: column; justify-content: center; padding: 48px 52px; }
.login-title { font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.login-tagline { font-size: 13.5px; color: #6b7280; margin-bottom: 32px; }
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label { font-size: 12.5px; font-weight: 500; color: #374151; }
.form-input { height: 42px; padding: 0 14px; border: 1.5px solid #d1d5db; border-radius: 8px; font-size: 13.5px; outline: none; transition: border-color .15s; width: 100%; }
.form-input:focus { border-color: var(--green); }
.form-input.is-error { border-color: #ef4444; }
.form-error-msg { font-size: 12px; color: #ef4444; margin-top: 4px; }
.btn-login { width: 100%; height: 44px; background: var(--green); color: #fff; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; margin-top: 8px; transition: opacity .15s; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-login:hover { opacity: .9; }
.btn-login:disabled { opacity: .7; cursor: default; }
.login-note { font-size: 11.5px; color: #9ca3af; text-align: center; margin-top: 20px; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 18px; }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .login-left { display: none; }
  .login-right { width: 100%; padding: 32px 24px; }
}
@media (max-width: 480px) { .stat-grid { grid-template-columns: 1fr; } }
