/* Admin & seller portals. Mobile-first: the top bar collapses into a menu button, tables become cards. */
:root {
  --brand: #188548;
  --brand-dark: #135532;
  --brand-soft: #eefbf3;
  --ink: #17201b;
  --muted: #5d6b63;
  --line: #e3e8e5;
  --surface: #f6f8f7;
  --red: #b42318;
  --red-soft: #fef3f2;
  --amber: #93370d;
  --amber-soft: #fffaeb;
  --blue: #175cd3;
  --blue-soft: #eff8ff;
  --radius: 14px;
  font-family: "Inter", "Hind Siliguri", ui-sans-serif, system-ui, -apple-system, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--surface); line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
p { margin: 0; }
img { max-width: 100%; }

/* ---------- Shell: dark top bar with dropdown menus ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { --bar: #0b1a0d; --bar-hover: rgb(255 255 255 / .08); --tab: #f1f5ea;
  position: sticky; top: 0; z-index: 40; background: var(--bar); color: #fff; }
.topbar-inner { display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 12px 0 16px; }

.brand { color: #fff; display: flex; align-items: center; gap: 10px; flex-shrink: 0; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 36px; width: auto; max-width: 170px; object-fit: contain; }
.brand-logo.on-chip { background: #fff; border-radius: 10px; padding: 4px 8px; height: 40px; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: 1.125rem; }
.brand-text { font-weight: 800; font-size: 1.125rem; letter-spacing: .02em; text-transform: uppercase; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-portal { align-self: flex-end; margin-bottom: 4px; font-weight: 700; font-size: .6875rem; letter-spacing: .12em; text-transform: uppercase;
  color: rgb(255 255 255 / .6); padding-left: 2px; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.icon-btn { position: relative; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: #fff; background: none; border: 0; cursor: pointer; }
.icon-btn:hover { background: var(--bar-hover); text-decoration: none; }
.icon-badge { position: absolute; top: 4px; right: 4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: #e5484d; color: #fff; font-size: .6875rem; font-weight: 700; display: grid; place-items: center; }
.avatar { width: 44px; height: 44px; border-radius: 50%; border: 0; background: #fff; color: var(--bar); font: inherit; font-weight: 800; font-size: .9375rem; cursor: pointer; }
.nav-group.account { position: relative; margin-left: 4px; }

/* Menu groups */
.topnav { display: none; }
.nav-group { position: relative; }
.nav-trigger { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; padding: 12px 14px; color: #fff; background: none; border: 0;
  font: inherit; font-size: .9375rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; cursor: pointer; border-radius: 10px; }
.nav-trigger:hover { background: var(--bar-hover); text-decoration: none; }
.chevron { transition: transform .15s; opacity: .85; }
.nav-group.open > .nav-trigger .chevron { transform: rotate(180deg); }
.nav-panel { display: none; }
.nav-group.open > .nav-panel { display: block; }
.nav-panel a, .nav-panel .panel-logout { display: block; width: 100%; padding: 10px 14px; border-radius: 8px; font: inherit; font-size: .9375rem; text-align: left; background: none; border: 0; cursor: pointer; }
.panel-user { padding: 10px 14px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; display: flex; flex-direction: column; font-size: .875rem; }
.panel-user span, .panel-label { color: var(--muted); font-size: .8125rem; }
.panel-store { padding: 6px 14px 10px; display: flex; flex-direction: column; gap: 4px; font-size: .875rem; }
.panel-logout { color: var(--red) !important; }

/* Phones & tablets: menu button opens the groups as a stacked list */
@media (max-width: 1023px) {
  .topbar.open .topnav { display: block; position: absolute; top: 100%; left: 0; right: 0; background: var(--bar); padding: 4px 12px 16px;
    max-height: calc(100vh - 64px); overflow-y: auto; border-top: 1px solid rgb(255 255 255 / .1); }
  .topnav .nav-panel { padding: 0 0 6px 12px; }
  .topnav .nav-subpanel { display: block; padding: 0 0 4px 16px; border-left: 1px solid rgb(255 255 255 / .12); margin-left: 14px; }
  .topnav .nav-subpanel a { font-size: .875rem; padding: 8px 12px; }
  .topnav .nav-sub-arrow { display: none; }
  .topnav .nav-panel a { color: rgb(255 255 255 / .85); }
  .topnav .nav-panel a:hover { background: var(--bar-hover); color: #fff; text-decoration: none; }
  .topnav .nav-panel a.active { background: var(--pick); color: #fff; }
  .topnav .nav-group.active > .nav-trigger { background: rgb(255 255 255 / .12); }
  .brand-portal { display: none; }
}

/* Dropdown panels: same dark green as the bar, white text, soft-green highlight */
.topbar { --panel: #0a1a0c; --pick: #45946f; }
.nav-panel-right { position: absolute; right: 0; top: calc(100% + 10px); min-width: 260px; background: var(--panel); color: #fff; border-radius: 10px;
  padding: 8px; box-shadow: 0 16px 40px rgb(0 0 0 / .35); }
.nav-panel-right .panel-user { border-color: rgb(255 255 255 / .12); }
.nav-panel-right .panel-user span, .nav-panel-right .panel-label { color: rgb(255 255 255 / .6); }
.nav-panel-right select { background: #13261a; color: #fff; border-color: rgb(255 255 255 / .2); }
.nav-panel a, .nav-panel .panel-logout { color: #fff; }
.nav-panel a:hover, .nav-panel .panel-logout:hover, .nav-panel a.active, .nav-sub:hover > .nav-sub-trigger, .nav-sub.active > .nav-sub-trigger,
.nav-sub:focus-within > .nav-sub-trigger { background: var(--pick); color: #fff; text-decoration: none; }
.nav-panel-right .panel-logout { color: #ff8a8a !important; }
.nav-panel-right .panel-logout:hover { color: #fff !important; }
.nav-sub-trigger { display: flex !important; align-items: center; justify-content: space-between; gap: 16px; }
.nav-sub-arrow { font-size: 1.25rem; line-height: 1; opacity: .9; }
.nav-subpanel a { display: block; }

@media (min-width: 1024px) {
  .topbar-inner { height: 76px; gap: 20px; padding: 0 24px 0 28px; }
  .nav-toggle { display: none; }
  .topnav { display: flex; align-self: stretch; align-items: stretch; gap: 2px; min-width: 0; }
  .topnav > .nav-group { display: flex; align-items: center; }
  .topnav .nav-trigger { height: 100%; width: auto; padding: 0 14px; border-radius: 0; }
  .topnav .nav-trigger:hover { background: var(--bar-hover); }
  /* Light tab under the section you're in, like a folder tab */
  .topnav > .nav-group.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: var(--tab); border-radius: 6px 6px 0 0; }
  .topnav .nav-panel { position: absolute; left: 0; top: 100%; min-width: 280px; background: var(--panel); border-radius: 0 0 10px 10px; padding: 10px;
    box-shadow: 0 16px 40px rgb(0 0 0 / .35); z-index: 50; }
  .topnav .nav-panel a { padding: 14px 16px; font-size: 1rem; font-weight: 500; }
  .topnav .nav-panel a.active { font-weight: 600; }
  /* Flyout submenu to the right, top-aligned with the panel */
  .nav-sub { position: relative; }
  .nav-subpanel { display: none; position: absolute; left: calc(100% + 10px); top: -10px; min-width: 260px; background: var(--panel); border-radius: 10px;
    padding: 10px; box-shadow: 0 16px 40px rgb(0 0 0 / .35); }
  .nav-subpanel::before { content: ""; position: absolute; left: -12px; top: 0; bottom: 0; width: 12px; } /* hover bridge */
  .nav-sub:hover > .nav-subpanel, .nav-sub:focus-within > .nav-subpanel { display: block; }
  /* Menus near the right edge open their flyouts to the left so they stay on screen */
  .topnav > .nav-group:nth-last-child(-n+2) .nav-subpanel { left: auto; right: calc(100% + 10px); }
  .topnav > .nav-group:nth-last-child(-n+2) .nav-subpanel::before { left: auto; right: -12px; }
  .main { width: 100%; max-width: 1440px; margin: 0 auto; }
}
@media (min-width: 1024px) and (max-width: 1279px) {
  .topnav .nav-trigger { padding: 0 9px; font-size: .8125rem; }
  .brand-portal { display: none; }
}

.main { flex: 1; min-width: 0; padding: 20px 16px 48px; }
@media (min-width: 1024px) { .main { padding: 32px 40px 64px; } }

/* ---------- Building blocks ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head p { color: var(--muted); font-size: .875rem; margin-top: 4px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
@media (min-width: 640px) { .card { padding: 20px; } }
.stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.split { display: grid; gap: 16px; }
@media (min-width: 1024px) { .split { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; } }
.muted { color: var(--muted); }
.small { font-size: .8125rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.right { text-align: right; }
.mt { margin-top: 16px; }

.stat .label { color: var(--muted); font-size: .8125rem; }
.stat .value { font-size: 1.5rem; font-weight: 700; margin-top: 4px; }

/* ---------- Buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-size: .875rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { color: var(--red); border-color: #fecdca; }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: .8125rem; }
.btn-block { width: 100%; }
.button_to { display: inline; }
form.inline { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: .875rem; font-weight: 500; }
.hint { font-size: .75rem; color: var(--muted); }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number], input[type=search],
input[type=datetime-local], input[type=date], input[type=file], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; font: inherit; font-size: 1rem; color: var(--ink);
}
@media (min-width: 640px) { input, select, textarea { font-size: .9375rem !important; } }
input:focus, select:focus, textarea:focus { outline: 2px solid #b0e9c7; border-color: var(--brand); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); }
.check { display: flex; align-items: center; gap: 8px; font-size: .875rem; }
.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form-grid .full { grid-column: 1 / -1; } }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.errors { background: var(--red-soft); color: var(--red); border: 1px solid #fecdca; border-radius: 10px; padding: 10px 14px; font-size: .875rem; }
.errors ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------- Flash & badges ---------- */
.flash { border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: .875rem; }
.flash-notice { background: var(--brand-soft); color: var(--brand-dark); border: 1px solid #b0e9c7; }
.flash-alert { background: var(--red-soft); color: var(--red); border: 1px solid #fecdca; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.badge-green { background: var(--brand-soft); color: var(--brand-dark); border-color: #b0e9c7; }
.badge-red { background: var(--red-soft); color: var(--red); border-color: #fecdca; }
.badge-amber { background: var(--amber-soft); color: var(--amber); border-color: #fedf89; }
.badge-blue { background: var(--blue-soft); color: var(--blue); border-color: #b2ddff; }

/* ---------- Tabs / filters ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 16px; padding-bottom: 2px; }
.tabs a { flex-shrink: 0; padding: 6px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--muted); font-size: .8125rem; font-weight: 500; }
.tabs a.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.tabs a:hover { text-decoration: none; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.toolbar input[type=search] { flex: 1; min-width: 200px; }

/* ---------- Responsive tables: cards on phones ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
/* Money columns: the heading lines up with its right-aligned figures (".table th" would otherwise win) */
.table th.right, .table td.right { text-align: right; }
.table td.right { font-variant-numeric: tabular-nums; }
.table-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
@media (max-width: 767px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .table tr:last-child { border-bottom: 0; }
  .table td { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border: 0; text-align: right; }
  .table td::before { content: attr(data-label); color: var(--muted); font-size: .75rem; text-align: left; flex-shrink: 0; padding-top: 2px; }
  .table td[data-label=""]::before { content: none; }
  .table td.primary { font-weight: 600; font-size: .9375rem; text-align: left; }
}
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

dl.details { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 8px 16px; margin: 0; font-size: .875rem; }
dl.details dt { color: var(--muted); }
dl.details dd { margin: 0; overflow-wrap: anywhere; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--line); font-size: .875rem; }
.timeline li { position: relative; padding-bottom: 12px; }
.timeline li::before { content: ""; position: absolute; left: -22px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(135deg, var(--brand-dark), var(--brand)); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 20px; padding: 28px; }

/* Product images (admin product form / edit page) */
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.image-grid:empty { display: none; }
.image-tile { position: relative; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.image-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.image-tile figcaption { gap: 6px; flex-wrap: wrap; font-size: .75rem; color: var(--muted); overflow-wrap: anywhere; }
.image-tile .image-main { position: absolute; top: 6px; left: 6px; background: var(--brand-soft); color: var(--brand-dark); border-color: #b0e9c7; }
.image-picker-error { color: var(--red); }

/* Notice boxes (also in mobile.css for the phone portals) */
.banner { border-radius: 12px; padding: 12px 14px; font-size: .875rem; }
.banner-warn { background: var(--amber-soft); color: var(--amber); border: 1px solid #fedf89; }
.banner-ok { background: var(--brand-soft); color: var(--brand-dark); border: 1px solid #b0e9c7; }

/* Period bar: preset ranges as a segmented control + a custom from–to range (Output → Accounts) */
.period-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; padding: 12px 16px; margin-bottom: 16px; }
.period-bar .period-title { display: flex; flex-direction: column; min-width: 0; }
.period-bar .period-title strong { font-size: .9375rem; }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.segmented a { padding: 6px 12px; border-radius: 8px; font-size: .8125rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.segmented a:hover { color: var(--ink); text-decoration: none; }
.segmented a.active { background: #fff; color: var(--brand-dark); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }
.period-range { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.period-range input[type=date] { width: auto; min-height: 36px; padding: 6px 10px; font-size: .875rem; }
.period-range .btn { min-height: 36px; }
.period-range .dash { color: var(--muted); }
