/* ===================================================================
   FMS Admin — Design system
   =================================================================== */

:root {
  /* Brand */
  --brand:        #6366f1;
  --brand-600:    #4f46e5;
  --brand-700:    #4338ca;
  --brand-soft:   rgba(99, 102, 241, 0.12);

  /* Light theme (default) */
  --bg:           #f5f6fb;
  --surface:      #ffffff;
  --surface-2:    #f8fafc;
  --border:       #e6e8f0;
  --text:         #1e2333;
  --text-muted:   #6b7280;
  --text-faint:   #9aa2b1;
  --shadow-sm:    0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md:    0 4px 16px rgba(16, 24, 40, 0.08);
  --shadow-lg:    0 20px 40px rgba(16, 24, 40, 0.12);

  --success:      #16a34a;
  --success-soft: rgba(22, 163, 74, 0.12);
  --danger:       #dc2626;
  --danger-soft:  rgba(220, 38, 38, 0.12);
  --warning:      #d97706;
  --warning-soft: rgba(217, 119, 6, 0.12);
  --info:         #0891b2;
  --info-soft:    rgba(8, 145, 178, 0.12);

  --sidebar-w:    260px;
  --sidebar-w-collapsed: 76px;
  --topbar-h:     64px;
  --radius:       14px;
  --radius-sm:    10px;
  --transition:   200ms cubic-bezier(.4, 0, .2, 1);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html[data-theme="dark"] {
  --bg:           #0b1020;
  --surface:      #141a2e;
  --surface-2:    #1b2338;
  --border:       #262f47;
  --text:         #e6e9f2;
  --text-muted:   #9aa4bd;
  --text-faint:   #6b7591;
  --shadow-sm:    0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md:    0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg:    0 20px 40px rgba(0, 0, 0, 0.5);
  --brand-soft:   rgba(99, 102, 241, 0.18);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 20px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: content-box; }

/* ===================================================================
   Layout
   =================================================================== */
.layout { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: width var(--transition), transform var(--transition);
}

.sidebar__brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  white-space: nowrap;
}
.sidebar__logo {
  width: 36px; height: 36px; flex: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #8b5cf6);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 18px;
  box-shadow: var(--shadow-sm);
}
.sidebar__name { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 16px 12px; }
.nav__label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-faint); font-weight: 600;
  padding: 14px 12px 6px;
}
.nav__item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.nav__item svg { width: 20px; height: 20px; flex: none; }
.nav__item:hover { background: var(--surface-2); color: var(--text); }
.nav__item.is-active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav__item.is-active svg { color: var(--brand); }
.nav__text { transition: opacity var(--transition); }

.sidebar__footer { padding: 12px; border-top: 1px solid var(--border); }

/* Collapsed (desktop) */
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .sidebar__name,
body.sidebar-collapsed .nav__text,
body.sidebar-collapsed .nav__label,
body.sidebar-collapsed .sidebar__footer .user-card__meta { opacity: 0; pointer-events: none; }
body.sidebar-collapsed .sidebar__brand { padding: 0; justify-content: center; }
body.sidebar-collapsed .nav__item { justify-content: center; }
body.sidebar-collapsed .main { margin-left: var(--sidebar-w-collapsed); }

/* ---- Main column ---- */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin var(--transition);
}

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-h);
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__title { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; flex: none; white-space: nowrap; }


.topbar__actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--text-faint); }
.icon-btn svg { width: 20px; height: 20px; }

/* Theme toggle icon swap */
.icon-btn .icon-sun { display: none; }
html[data-theme="dark"] .icon-btn .icon-sun { display: block; }
html[data-theme="dark"] .icon-btn .icon-moon { display: none; }

/* ---- User menu ---- */
.usermenu { position: relative; }
.usermenu__trigger {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 6px 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  transition: all var(--transition);
}
.usermenu__trigger:hover { background: var(--surface-2); }
.usermenu__dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: all var(--transition);
}
.usermenu.open .usermenu__dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.usermenu__head { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.usermenu__head strong { display: block; font-size: 14px; }
.usermenu__head span { font-size: 12px; color: var(--text-muted); }
.menu__item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 14px; font-weight: 500;
  width: 100%; border: none; background: none; text-align: left;
}
.menu__item svg { width: 18px; height: 18px; }
.menu__item:hover { background: var(--surface-2); color: var(--text); }
.menu__item.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* Avatar */
.avatar {
  width: 32px; height: 32px; flex: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), #8b5cf6);
  color: #fff; font-weight: 700; font-size: 13px;
  display: grid; place-items: center;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--lg { width: 88px; height: 88px; font-size: 32px; border-radius: 24px; }

/* ---- Content ---- */
.content { padding: 28px 24px; max-width: 1400px; width: 100%; margin: 0 auto; }
.page-head { margin-bottom: 24px; }
.page-head h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -0.02em; }
.page-head p { margin: 0; color: var(--text-muted); }

/* ===================================================================
   Components
   =================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card--link { display: block; transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition); }
.card--link:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--brand); }
.card__body { padding: 22px; }
.card__head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.card__head h3 { margin: 0; font-size: 16px; }

.grid { display: grid; gap: 20px; }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid--profile { grid-template-columns: minmax(0, 340px) 1fr; align-items: start; }

.form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.stack { display: flex; flex-direction: column; gap: 20px; }

/* Stat card */
.stat { display: flex; align-items: flex-start; gap: 16px; }
.stat__icon {
  width: 48px; height: 48px; flex: none;
  border-radius: 12px; display: grid; place-items: center;
}
.stat__icon svg { width: 24px; height: 24px; }
.stat__icon.brand  { background: var(--brand-soft);   color: var(--brand); }
.stat__icon.green  { background: var(--success-soft); color: var(--success); }
.stat__icon.amber  { background: var(--warning-soft); color: var(--warning); }
.stat__icon.cyan   { background: var(--info-soft);    color: var(--info); }
.stat__value { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.stat__label { color: var(--text-muted); font-size: 13.5px; }
.stat__delta { font-size: 12.5px; font-weight: 600; margin-top: 6px; display: inline-flex; align-items: center; gap: 4px; }
.stat__delta.up { color: var(--success); }
.stat__delta.down { color: var(--danger); }

/* Badge */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.amber { background: var(--warning-soft); color: var(--warning); }
.badge.red   { background: var(--danger-soft);  color: var(--danger); }
.badge.gray  { background: var(--surface-2);    color: var(--text-muted); }
.badge.brand { background: var(--brand-soft);   color: var(--brand); }
.badge.cyan  { background: var(--info-soft);    color: var(--info); }

/* Table */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; min-width: 560px; }
.table th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-faint); font-weight: 600; padding: 12px 22px; border-bottom: 1px solid var(--border);
}
.table td { padding: 14px 22px; border-bottom: 1px solid var(--border); font-size: 14px; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--surface-2); }
.cell-user { display: flex; align-items: center; gap: 12px; }
.cell-user small { color: var(--text-muted); }

/* ===================================================================
   Forms & buttons
   =================================================================== */
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 7px; }
.input {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 15px; font-family: inherit;
  transition: border var(--transition), box-shadow var(--transition);
}
.input::placeholder { color: var(--text-faint); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input-group { position: relative; }
.input-group .input { padding-right: 44px; }
.input-group__btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border: none; background: none; color: var(--text-faint);
  display: grid; place-items: center; border-radius: 8px;
}
.input-group__btn:hover { color: var(--text); background: var(--surface-2); }
.input-group__btn svg { width: 20px; height: 20px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 14.5px; border: 1px solid transparent;
  transition: all var(--transition);
}
.btn svg { width: 18px; height: 18px; }
.btn--primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--brand-600); }
.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--block { width: 100%; }
.btn--lg { padding: 14px 20px; font-size: 15px; }

/* ===================================================================
   Alerts
   =================================================================== */
.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 14px; margin-bottom: 16px; font-weight: 500;
}
.alert svg { width: 18px; height: 18px; flex: none; }
.alert--error   { background: var(--danger-soft);  color: var(--danger); }
.alert--success { background: var(--success-soft); color: var(--success); }
.alert--info    { background: var(--info-soft);    color: var(--info); }

/* ===================================================================
   Auth page
   =================================================================== */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr;
}
.auth__aside {
  position: relative; overflow: hidden;
  background: linear-gradient(150deg, var(--brand-700), var(--brand), #8b5cf6);
  color: #fff; padding: 56px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.auth__aside::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 80% 20%, rgba(255,255,255,.18), transparent 40%),
              radial-gradient(circle at 10% 90%, rgba(255,255,255,.12), transparent 45%);
}
.auth__aside > * { position: relative; z-index: 1; }
.auth__brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 20px; }
.auth__brand .sidebar__logo { background: rgba(255,255,255,.2); }
.auth__pitch h2 { font-size: 34px; line-height: 1.2; margin: 0 0 14px; letter-spacing: -0.02em; }
.auth__pitch p { font-size: 16px; opacity: .85; margin: 0; max-width: 40ch; }
.auth__features { display: flex; flex-direction: column; gap: 14px; }
.auth__feature { display: flex; align-items: center; gap: 12px; font-size: 15px; opacity: .95; }
.auth__feature svg { width: 20px; height: 20px; flex: none; }

.auth__main { display: grid; place-items: center; padding: 40px 24px; position: relative; }
.auth__theme { position: absolute; top: 24px; right: 24px; }
.auth__card { width: 100%; max-width: 400px; }
.auth__card h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -0.02em; }
.auth__card .sub { color: var(--text-muted); margin: 0 0 28px; }
.auth__hint {
  margin-top: 20px; padding: 12px 14px; font-size: 13px;
  background: var(--surface-2); border: 1px dashed var(--border);
  border-radius: var(--radius-sm); color: var(--text-muted);
}

/* ===================================================================
   Overlay (mobile sidebar)
   =================================================================== */
.overlay {
  position: fixed; inset: 0; background: rgba(3, 7, 18, 0.5);
  opacity: 0; visibility: hidden; transition: opacity var(--transition); z-index: 39;
}
body.sidebar-open .overlay { opacity: 1; visibility: visible; }

/* Hamburger only on mobile */
.topbar__toggle { display: grid; }

/* ===================================================================
   Responsive
   =================================================================== */
@media (max-width: 1024px) {
  .auth { grid-template-columns: 1fr; }
  .auth__aside { display: none; }
}

@media (max-width: 900px) {
  .grid--profile { grid-template-columns: 1fr; }
  .form-2col { grid-template-columns: 1fr; gap: 0; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w); }
  body.sidebar-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }
  /* On mobile, collapsed state is irrelevant — always full width when open */
  body.sidebar-collapsed .sidebar { width: var(--sidebar-w); }
  body.sidebar-collapsed .sidebar__name,
  body.sidebar-collapsed .nav__text,
  body.sidebar-collapsed .nav__label { opacity: 1; }
  body.sidebar-collapsed .nav__item { justify-content: flex-start; }
  body.sidebar-collapsed .sidebar__brand { padding: 0 20px; justify-content: flex-start; }
  .main, body.sidebar-collapsed .main { margin-left: 0; }
  .content { padding: 20px 16px; }
  .topbar { padding: 0 16px; }
  .topbar__title { font-size: 16px; }
  .usermenu__name { display: none; }
}

@media (min-width: 769px) {
  .topbar__toggle .icon-collapse { display: block; }
}

/* ===================================================================
   Toolbar / filters
   =================================================================== */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  margin-bottom: 20px;
}
.search-box { position: relative; flex: 1 1 260px; min-width: 200px; }
.search-box svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--text-faint); pointer-events: none;
}
.search-box .input { padding-left: 42px; }
.toolbar .select { min-width: 160px; }
.toolbar__spacer { flex: 1; }

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239aa2b1' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='m19.5 8.25-7.5 7.5-7.5-7.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  padding-right: 38px;
  cursor: pointer;
}

/* ===================================================================
   Toggle switch
   =================================================================== */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border); border-radius: 999px;
  transition: background var(--transition);
}
.switch .track::before {
  content: ""; position: absolute; left: 3px; top: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25);
  transition: transform var(--transition);
}
.switch input:checked + .track { background: var(--success); }
.switch input:checked + .track::before { transform: translateX(18px); }
.switch input:disabled + .track { opacity: .5; cursor: not-allowed; }

/* ===================================================================
   Action buttons in tables
   =================================================================== */
.row-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.icon-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  transition: all var(--transition);
}
.icon-link svg { width: 16px; height: 16px; }
.icon-link:hover { background: var(--surface-2); color: var(--text); }
.icon-link.danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-soft); }
.icon-link.warn:hover { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-soft); }

/* ===================================================================
   Pagination
   =================================================================== */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; flex-wrap: wrap; }
.pagination__info { font-size: 13px; color: var(--text-muted); }
.pagination__pages { display: flex; gap: 6px; }
.pagination__pages a, .pagination__pages span {
  min-width: 34px; height: 34px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  font-size: 13.5px; font-weight: 600; color: var(--text-muted);
}
.pagination__pages a:hover { background: var(--surface-2); color: var(--text); }
.pagination__pages .is-current { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ===================================================================
   Timeline (customer history)
   =================================================================== */
.timeline { display: flex; flex-direction: column; }
.timeline__item { position: relative; padding: 0 0 20px 28px; border-left: 2px solid var(--border); margin-left: 8px; }
.timeline__item:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline__dot {
  position: absolute; left: -7px; top: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--brand); border: 2px solid var(--surface);
}
.timeline__head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.timeline__action { font-weight: 700; font-size: 13.5px; }
.timeline__meta { font-size: 12.5px; color: var(--text-faint); }
.timeline__note { font-size: 13.5px; color: var(--text-muted); background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 4px; }

/* Field hint / error text */
.field .hint { font-size: 12.5px; color: var(--text-faint); margin-top: 6px; }
.field .input.has-error { border-color: var(--danger); }

/* Empty state */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state svg { width: 44px; height: 44px; margin: 0 auto 12px; color: var(--text-faint); }
.empty-state h4 { margin: 0 0 6px; color: var(--text); }

/* ===================================================================
   Dashboard: global search, period stat grid, chart legend, activity feed
   =================================================================== */
.gsearch { display: flex; align-items: stretch; width: 100%; max-width: 520px; }
.gsearch__select {
  flex: none; height: 44px; padding: 0 12px;
  border: 1px solid var(--border); border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  background: var(--surface-2); color: var(--text-muted);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.gsearch__select:focus { outline: none; }
.gsearch__box { position: relative; flex: 1; min-width: 0; }
.gsearch__box svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--text-faint); pointer-events: none;
}
.gsearch__input {
  width: 100%; height: 44px; padding: 0 14px 0 40px;
  border: 1px solid var(--border); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface); color: var(--text);
  font-size: 14.5px; font-family: inherit;
  transition: border var(--transition), box-shadow var(--transition);
}
.gsearch__input::placeholder { color: var(--text-faint); }
.gsearch__input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); z-index: 1; position: relative; }

.gsearch__dropdown {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); max-height: 340px; overflow-y: auto; z-index: 50;
  display: none;
}
.gsearch__dropdown.open { display: block; }
.gsearch__item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.gsearch__item:last-child { border-bottom: none; }
.gsearch__item:hover, .gsearch__item:focus { background: var(--surface-2); }
.gsearch__item-title { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.gsearch__item-meta { font-size: 12.5px; color: var(--text-muted); flex: none; }
.gsearch__empty { padding: 16px; text-align: center; color: var(--text-muted); font-size: 13px; }

.period-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.period-cell { padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.period-cell__label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 6px; }
.period-cell__value { font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }
.period-cell__value.green { color: var(--success); }

.legend-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend-dot.brand { background: linear-gradient(180deg, var(--brand), #8b5cf6); }
.legend-dot.green { background: linear-gradient(180deg, var(--success), #22c55e); }

.feed { display: flex; flex-direction: column; padding: 8px; max-height: 420px; overflow-y: auto; }
.feed__item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.feed__item:hover { background: var(--surface-2); }
.feed__body { min-width: 0; }
.feed__title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed__title.green { color: var(--success); }
.feed__meta { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 640px) {
  .toolbar .select { flex: 1 1 140px; min-width: 0; }
  .pagination { flex-direction: column; align-items: flex-start; }
  .period-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  /* iOS Safari auto-zooms on focus for inputs under 16px — keep this at 16px on mobile. */
  .gsearch__input, .gsearch__select { font-size: 16px; }
}
