/* admin.css — Ambady Admin Suite */

:root {
  --a-bg: #f4f1ea;
  --a-panel: #ffffff;
  --a-panel-2: #faf8f3;
  --a-ink: #1f2418;
  --a-muted: #76796e;
  --a-line: rgba(31,36,24,0.10);
  --a-line-2: rgba(31,36,24,0.18);
  --a-forest: #2f4a1f;
  --a-forest-2: #3c5e29;
  --a-maroon: #9c2f22;
  --a-maroon-d: #7a2419;
  --a-sage: #b7c39a;
  --a-cream: #f1ead9;
  --a-gold: #b08a3c;
  --a-blue: #2f6fd1;
  --a-green: #2f8a4f;
  --a-amber: #c98a1e;
  --a-red: #c0392b;
  --a-sidebar: #1c2616;
  --a-radius: 12px;
  --a-shadow: 0 1px 3px rgba(31,36,24,0.06), 0 6px 20px rgba(31,36,24,0.05);
  --a-shadow-lg: 0 18px 50px rgba(31,36,24,0.16);
  --a-serif: "Instrument Serif", Georgia, serif;
  --a-sans: "DM Sans", system-ui, -apple-system, sans-serif;
  --a-mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--a-sans); background: var(--a-bg); color: var(--a-ink); -webkit-font-smoothing: antialiased; font-size: 14px; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
h1,h2,h3,h4 { margin: 0; font-weight: 600; }
img { display: block; max-width: 100%; }
table { border-collapse: collapse; width: 100%; }
.serif { font-family: var(--a-serif); font-weight: 400; }

/* ---- Layout ---- */
.admin { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--a-sidebar); color: #e8ebe2; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; overflow-y: auto;
}
.sidebar__brand { padding: 22px 20px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar__brand .mark { font-family: var(--a-sans); font-weight: 700; letter-spacing: .12em; font-size: 1.05rem; color: #fff; line-height: 1; }
.sidebar__brand .sub { font-size: 8px; letter-spacing: .28em; text-transform: uppercase; color: var(--a-sage); margin-top: 3px; }
.sidebar__nav { padding: 12px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar__section { font-size: .64rem; letter-spacing: .16em; text-transform: uppercase; color: rgba(255,255,255,0.4); padding: 14px 12px 6px; }
.nav-link { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px; color: rgba(255,255,255,0.78); font-size: .88rem; font-weight: 500; transition: background .15s, color .15s; }
.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-link.active { background: var(--a-forest-2); color: #fff; }
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }
.nav-link .count { margin-left: auto; background: rgba(255,255,255,0.14); border-radius: 999px; padding: 1px 7px; font-size: .7rem; }
.nav-link.active .count { background: var(--a-maroon); }
.sidebar__foot { padding: 14px; border-top: 1px solid rgba(255,255,255,0.08); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--a-panel); border-bottom: 1px solid var(--a-line); padding: 14px 28px; display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 20; }
.topbar h1 { font-size: 1.15rem; font-weight: 600; }
.topbar__spacer { flex: 1; }
.content { padding: 28px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 9px; font-size: .85rem; font-weight: 600; transition: all .15s; white-space: nowrap; border: 1px solid transparent; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--a-forest); color: #fff; }
.btn-primary:hover { background: var(--a-forest-2); }
.btn-maroon { background: var(--a-maroon); color: #fff; }
.btn-maroon:hover { background: var(--a-maroon-d); }
.btn-ghost { background: transparent; color: var(--a-ink); border-color: var(--a-line-2); }
.btn-ghost:hover { background: var(--a-panel-2); }
.btn-soft { background: var(--a-cream); color: var(--a-ink); }
.btn-soft:hover { background: #e8e0cd; }
.btn-danger { background: transparent; color: var(--a-red); border-color: rgba(192,57,43,0.35); }
.btn-danger:hover { background: rgba(192,57,43,0.08); }
.btn-sm { padding: 6px 11px; font-size: .78rem; border-radius: 8px; }
.btn-icon { padding: 8px; width: 34px; height: 34px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Cards / panels ---- */
.card { background: var(--a-panel); border: 1px solid var(--a-line); border-radius: var(--a-radius); box-shadow: var(--a-shadow); }
.card-pad { padding: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--a-line); }
.panel-head h2 { font-size: 1rem; }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.kpi { background: var(--a-panel); border: 1px solid var(--a-line); border-radius: var(--a-radius); padding: 18px 20px; box-shadow: var(--a-shadow); }
.kpi__label { font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; color: var(--a-muted); display: flex; align-items: center; gap: 8px; }
.kpi__label svg { width: 16px; height: 16px; color: var(--a-forest); }
.kpi__value { font-family: var(--a-serif); font-size: 2.1rem; line-height: 1.1; margin-top: 8px; }
.kpi__delta { font-size: .76rem; margin-top: 4px; }
.kpi__delta.up { color: var(--a-green); }
.kpi__delta.down { color: var(--a-red); }

/* ---- Tables ---- */
.tbl { font-size: .86rem; }
.tbl th { text-align: left; padding: 11px 14px; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--a-muted); border-bottom: 1px solid var(--a-line); font-weight: 600; white-space: nowrap; }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--a-line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--a-panel-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--a-cream); }

/* ---- Badges ---- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: .72rem; font-weight: 600; white-space: nowrap; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; }
.b-in { background: rgba(47,138,79,0.12); color: var(--a-green); }
.b-low { background: rgba(201,138,30,0.14); color: var(--a-amber); }
.b-out { background: rgba(192,57,43,0.12); color: var(--a-red); }
.b-new { background: rgba(47,111,209,0.12); color: var(--a-blue); }
.b-packed { background: rgba(176,138,60,0.16); color: var(--a-gold); }
.b-shipped { background: rgba(47,111,209,0.12); color: var(--a-blue); }
.b-out_for_delivery { background: rgba(201,138,30,0.16); color: var(--a-amber); }
.b-delivered { background: rgba(47,138,79,0.14); color: var(--a-green); }
.b-cancelled { background: rgba(118,121,110,0.16); color: var(--a-muted); }
.b-returned { background: rgba(192,57,43,0.12); color: var(--a-red); }

/* ---- Forms ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .74rem; letter-spacing: .04em; color: var(--a-muted); font-weight: 600; }
.inp, .sel, .ta { background: var(--a-panel); border: 1px solid var(--a-line-2); border-radius: 9px; padding: 10px 12px; font-size: .88rem; width: 100%; transition: border-color .15s; }
.inp:focus, .sel:focus, .ta:focus { outline: none; border-color: var(--a-forest); }
.ta { resize: vertical; min-height: 80px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .span2 { grid-column: span 2; }

/* ---- Modal ---- */
.scrim { position: fixed; inset: 0; background: rgba(31,36,24,0.4); backdrop-filter: blur(2px); z-index: 100; display: grid; place-items: center; padding: 24px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--a-panel); border-radius: 16px; width: 100%; max-width: 720px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--a-shadow-lg); overflow: hidden; animation: pop .2s; }
.modal-lg { max-width: 980px; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
.modal__head { padding: 18px 22px; border-bottom: 1px solid var(--a-line); display: flex; align-items: center; justify-content: space-between; }
.modal__head h2 { font-size: 1.1rem; }
.modal__body { padding: 22px; overflow-y: auto; }
.modal__foot { padding: 16px 22px; border-top: 1px solid var(--a-line); display: flex; justify-content: flex-end; gap: 10px; background: var(--a-panel-2); }

/* ---- Misc ---- */
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 4px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--a-muted); }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.search-box { position: relative; flex: 1; max-width: 360px; }
.search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--a-muted); }
.search-box input { padding-left: 36px; }
.chip { padding: 6px 12px; border-radius: 999px; font-size: .8rem; background: var(--a-panel); border: 1px solid var(--a-line-2); transition: all .15s; }
.chip:hover { border-color: var(--a-forest); }
.chip.active { background: var(--a-forest); color: #fff; border-color: var(--a-forest); }
.section-title { font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--a-muted); margin-bottom: 12px; font-weight: 600; }

.photo-cell { width: 84px; height: 84px; border-radius: 10px; overflow: hidden; background: var(--a-cream); position: relative; border: 1px solid var(--a-line); }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.photo-add { border: 1.5px dashed var(--a-line-2); border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 4px; color: var(--a-muted); font-size: .72rem; aspect-ratio: 1; cursor: pointer; transition: all .15s; }
.photo-add:hover { border-color: var(--a-forest); color: var(--a-forest); background: var(--a-panel-2); }

.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: grid; grid-template-columns: 28px 1fr; gap: 12px; padding-bottom: 18px; position: relative; }
.tl-item:not(:last-child)::before { content: ''; position: absolute; left: 13px; top: 24px; bottom: 0; width: 2px; background: var(--a-line); }
.tl-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--a-forest); color: #fff; }
.tl-dot svg { width: 14px; height: 14px; }
.tl-dot.pending { background: var(--a-cream); color: var(--a-muted); }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--a-sidebar); padding: 24px; }
.login-card { background: var(--a-panel); border-radius: 18px; padding: 40px; width: 100%; max-width: 400px; box-shadow: var(--a-shadow-lg); }

/* print */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .admin { display: block; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
}

@media (max-width: 900px) {
  .admin { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 240px; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--a-shadow-lg); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }
}
.menu-toggle { display: none; }
@media (max-width: 900px) { .menu-toggle { display: inline-flex; } }

/* ---- Owner ERP shell extensions ---- */
.tenant-chip {
  margin: 10px 14px 0; padding: 8px 10px; border-radius: 8px;
  background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.7);
  font-size: .68rem; line-height: 1.35;
}
.cap-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.cap-live { background: #3dba6f; }
.cap-partial { background: #d4a017; }
.cap-blocked { background: #c0392b; }
.mode-banner {
  background: #fff8e8; border: 1px solid rgba(176,138,60,0.35); color: #5c4a1e;
  padding: 10px 14px; border-radius: 10px; font-size: .8rem; margin-bottom: 16px; line-height: 1.45;
}
.banner-err { background: rgba(192,57,43,0.1); color: var(--a-red); padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-size: .84rem; }
.banner-ok { background: rgba(47,138,79,0.1); color: var(--a-green); padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-size: .84rem; }
.cc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.cc-grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.action-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.action-list a, .linkish { color: var(--a-forest); font-weight: 600; font-size: .9rem; text-align: left; }
.seg-control { display: inline-flex; border: 1px solid var(--a-line-2); border-radius: 9px; overflow: hidden; }
.seg { padding: 7px 12px; font-size: .78rem; font-weight: 600; background: var(--a-panel); }
.seg.on { background: var(--a-forest); color: #fff; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 130px; padding-top: 8px; }
.spark__col { flex: 1; display: flex; align-items: flex-end; min-width: 0; }
.spark__bar { width: 100%; background: var(--a-forest); border-radius: 3px 3px 0 0; opacity: .85; min-height: 2px; }
.card-list { display: flex; flex-direction: column; }
.card-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--a-line); }
.card-row:last-child { border-bottom: 0; }
.topbar__titles { min-width: 0; }
.crumbs { font-size: .7rem; letter-spacing: .04em; }
.gs { position: relative; flex: 1; max-width: 420px; min-width: 140px; }
.gs__box { max-width: none; }
.gs__panel {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--a-panel);
  border: 1px solid var(--a-line); border-radius: 12px; box-shadow: var(--a-shadow-lg); z-index: 40;
  max-height: 320px; overflow: auto;
}
.gs__item { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 10px 12px; border-bottom: 1px solid var(--a-line); }
.gs__item:hover { background: var(--a-panel-2); }
.gs__id { grid-column: 2; font-size: .72rem; color: var(--a-muted); font-family: var(--a-mono); }
.gs__title { grid-column: 2; font-size: .88rem; font-weight: 600; }
.gs__empty { padding: 14px; }
.qa { position: relative; }
.qa__menu {
  position: absolute; right: 0; top: calc(100% + 6px); background: var(--a-panel); border: 1px solid var(--a-line);
  border-radius: 10px; box-shadow: var(--a-shadow-lg); min-width: 180px; z-index: 40; padding: 6px;
}
.qa__menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 8px; font-size: .84rem; }
.qa__menu button:hover { background: var(--a-panel-2); }
.profile-chip { font-size: .78rem; }
.scrim-nav { position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 50; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.rinpo-answer { margin-top: 14px; padding: 12px; background: var(--a-cream); border-radius: 10px; }
.bottom-nav { display: none; }
.mobile-cards { display: none; }

@media (max-width: 1100px) {
  .cc-grid { grid-template-columns: 1fr; }
  .cc-grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .content { padding: 16px 14px 88px; }
  .topbar { padding: 10px 12px; flex-wrap: wrap; }
  .gs { order: 5; flex: 1 1 100%; max-width: none; }
  .profile-chip { display: none; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0;
    background: var(--a-panel); border-top: 1px solid var(--a-line); z-index: 40; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a {
    display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .62rem; color: var(--a-muted); padding: 6px 2px;
  }
  .bottom-nav a.on { color: var(--a-forest); font-weight: 700; }
  .table-scroll .tbl { min-width: 720px; }
  .mobile-cards { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
  .mobile-cards .m-card { background: var(--a-panel); border: 1px solid var(--a-line); border-radius: 12px; padding: 12px; }
  @media (max-width: 900px) {
    .orders-desktop-only { display: none; }
  }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

