:root {
  --green: #0f9f63;
  --green-bright: #15c978;
  --ink: #07110f;
  --muted: #66746f;
  --line: rgba(7, 28, 23, 0.1);
  --side: #061412;
  --side-soft: #0b211d;
  --bg: #f6f8f8;
}

* {
  box-sizing: border-box;
}

html {
  max-width: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  overflow-x: clip;
}
a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

[data-admin-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

[data-admin-icon] svg {
  width: 20px;
  height: 20px;
}

.guard-card {
  display: grid;
  width: min(440px, calc(100% - 32px));
  margin: 12vh auto 0;
  gap: 16px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(8, 34, 28, 0.14);
}

.guard-card[hidden],
.admin-app[hidden] {
  display: none;
}

.guard-card h1,
.guard-card p {
  margin: 0;
}

.guard-card p {
  color: var(--muted);
}

.guard-card label {
  display: grid;
  gap: 8px;
  font-weight: 800;
}

.guard-card input {
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
}

.guard-card button {
  height: 48px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--green-bright), var(--green));
  font-weight: 900;
}

.guard-card a {
  color: var(--green);
  font-weight: 800;
  text-align: center;
}

.admin-app {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  align-items: start;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: 260px;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(180deg, #071715, #06100f);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.sidebar::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* side-nav ambil semua sisa tinggi dan scroll sendiri */
.side-nav {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 12px 22px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.side-nav::-webkit-scrollbar { display: none; }

/* Logout selalu di paling bawah, tidak ikut scroll */
.logout {
  flex-shrink: 0;
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 10px;
  width: calc(100% - 24px);
  margin: 0 12px 12px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: #e02d3c;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(224, 45, 60, 0.35);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 24px;
  font-weight: 900;
  line-height: 0.92;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 2px solid var(--green-bright);
  border-radius: 10px;
  color: var(--green-bright);
  box-shadow: 0 0 24px rgba(21, 201, 120, 0.25);
  font-size: 13px;
  font-weight: 900;
}

.admin-profile {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 12px;
  align-items: center;
  margin: 0 14px 20px;
  padding: 18px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.avatar {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, #2a7f6a, #101a18);
  font-weight: 900;
}

.admin-profile b,
.top-profile b {
  display: block;
}

.admin-profile p,
.top-profile p {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
}

.admin-profile i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green-bright);
}

.side-nav {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 12px 22px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.side-nav::-webkit-scrollbar { display: none; }

.side-nav p {
  margin: 18px 10px 8px;
  color: rgba(255, 255, 255, 0.48);
  font-size: 12px;
  text-transform: uppercase;
}

.side-nav a,
.logout {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.84);
  font-weight: 700;
  font-size: 14px;
}

.side-nav a.active {
  color: #fff;
  background: linear-gradient(135deg, var(--green), #087348);
}

.side-nav em {
  margin-left: auto;
  padding: 2px 7px;
  border-radius: 999px;
  color: #fff;
  background: var(--green);
  font-style: normal;
  font-size: 11px;
}

.side-nav em.warn {
  background: #f7a51b;
}

.side-nav em.live-pill {
  background: #10b981;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  animation: pulseLive 2s infinite;
}

@keyframes pulseLive {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.content {
  grid-column: 2;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  padding: 0 28px 24px;
}

.top-admin {
  display: grid;
  grid-template-columns: 34px 1fr 240px 44px auto;
  gap: 18px;
  align-items: center;
  min-height: 92px;
  border-bottom: 1px solid var(--line);
}

.menu-button,
.bell {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.top-admin h1,
.top-admin p {
  margin: 0;
}

.top-admin h1 {
  font-size: 26px;
}

.top-admin p {
  margin-top: 5px;
  color: #4f5e59;
}

.top-admin select {
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.bell {
  position: relative;
}

.bell b {
  position: absolute;
  right: 3px;
  top: 1px;
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #ef3d4c;
  font-size: 10px;
}

.top-profile {
  display: grid;
  grid-template-columns: 42px auto auto;
  gap: 12px;
  align-items: center;
}

.top-profile p {
  color: var(--muted);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 18px;
  margin: 26px 0 20px;
}

.metric-grid article,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 26px rgba(23, 44, 39, 0.05);
}

.metric-grid article {
  display: flex;
  gap: 18px;
  align-items: center;
  min-height: 118px;
  padding: 20px;
}

.metric-grid article > span {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border-radius: 12px;
}

.green { color: var(--green); background: #e9f9f1; }
.blue { color: #2384d7; background: #e8f3ff; }
.yellow { color: #dda02a; background: #fff7df; }
.purple { color: #964fe5; background: #f1e8ff; }
.red { color: #e84c63; background: #ffe9ee; }

.metric-grid p {
  margin: 0 0 9px;
  color: #56655f;
  font-weight: 700;
}

.metric-grid strong {
  display: block;
  font-size: 24px;
}

.metric-grid em,
.finance em {
  display: block;
  margin-top: 12px;
  color: var(--green);
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  padding: 20px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.panel h2,
.panel-head h2 {
  margin: 0;
  font-size: 18px;
}

.panel-head a {
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
}

.panel-head button {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.legend {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 8px 0 10px 80px;
  color: #5d6964;
  font-size: 12px;
}

.legend span {
  width: 28px;
  height: 3px;
  border-radius: 999px;
}

.legend .sales { background: var(--green); }
.legend .orders { background: #9aa4a0; }

.line-chart {
  position: relative;
  display: grid;
  grid-template-columns: 64px 1fr;
  height: 240px;
  color: #56655f;
  font-size: 12px;
}

.line-chart > span {
  grid-column: 1;
  height: 40px;
}

.line-chart svg {
  grid-column: 2;
  grid-row: 1 / 7;
  width: 100%;
  height: 205px;
  background-image: linear-gradient(#edf1f0 1px, transparent 1px);
  background-size: 100% 40px;
}

.line-chart polyline {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sales-line { stroke: var(--green); }
.orders-line { stroke: #a7b0ad; }

.x-axis {
  grid-column: 2;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  color: #4f5e59;
}

.donut-wrap {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 28px;
  align-items: center;
  min-height: 250px;
}

.donut {
  display: grid;
  width: 210px;
  height: 210px;
  place-items: center;
  place-content: center;
  border-radius: 50%;
  background:
    radial-gradient(circle, #fff 0 43%, transparent 44%),
    conic-gradient(#ffc332 0 42deg, #288ae8 42deg 151deg, var(--green) 151deg 307deg, #934ce8 307deg 349deg, #f34450 349deg 360deg);
}

.donut strong {
  font-size: 32px;
}

.donut span {
  color: var(--muted);
}

.status-panel ul,
.best-products ol,
.customers ul,
.low-stock ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.status-panel li {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 10px;
  align-items: center;
  margin: 18px 0;
  color: #4f5e59;
}

.status-panel i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.yellow-dot { background: #ffc332; }
.blue-dot { background: #288ae8; }
.green-dot { background: var(--green); }
.purple-dot { background: #934ce8; }
.red-dot { background: #f34450; }

.lower-grid {
  display: grid;
  grid-template-columns: 1.08fr 0.95fr 1.08fr;
  gap: 18px;
  margin-bottom: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 12px 8px;
  border-top: 1px solid var(--line);
  text-align: left;
}

th {
  color: #4c5b56;
}

td span {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.paid { color: #1e80c7; background: #e8f3ff; }
.wait { color: #b47a00; background: #fff4d8; }
.ship { color: var(--green); background: #eaf9f2; }
.done { color: #884fe2; background: #f1e8ff; }
.cancel { color: #e34b5b; background: #ffe9ee; }

.best-products li,
.low-stock li {
  display: grid;
  grid-template-columns: 28px 38px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.best-products li span {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.best-products i,
.low-stock i,
i.sprite,
.sprite {
  display: inline-block;
  background-image: url("assets/grocery-sprite.png");
  background-repeat: no-repeat;
  background-size: 800% 200%;
}

.best-products i,
.low-stock i {
  display: block;
  width: 30px;
  height: 38px;
  background-position-y: 100%;
}

.rice-pack { background-position-x: 0 !important; }
.oil-pack { background-position-x: 14.285% !important; }
.sugar-pack { background-position-x: 28.57% !important; }
.noodle-pack { background-position-x: 42.855% !important; }
.flour-pack { background-position-x: 57.14% !important; }
.canned-pack { background-position-x: 71.425% !important; }
.spices { background-position-x: 85.71% !important; }
.cereal { background-position-x: 100% !important; }

.best-products strong {
  font-size: 13px;
}

.customers li {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.customers li span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--green), #273a36);
  font-size: 11px;
  font-weight: 900;
}

.customers p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.customers time {
  color: var(--muted);
  font-size: 12px;
}

.bottom-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 18px;
}

.finance > div {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 20px;
}

.finance span {
  display: block;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.finance p {
  margin: 0 0 12px;
  color: #4f5e59;
}

.finance b {
  font-size: 18px;
}

.low-stock li {
  grid-template-columns: 38px 1fr auto;
}

.low-stock b {
  color: #e34b5b;
}

.quick-panel > div {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.quick-panel button {
  display: grid;
  min-height: 86px;
  place-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 800;
}

.quick-panel button span {
  color: var(--green);
}

.admin-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 4px 0;
  color: #596863;
  font-size: 13px;
}

/* ── Global: hanya wrapper tabel yang scroll, bukan seluruh halaman ── */
.table-scroll,
.income-table-wrap,
.expense-table-wrap,
.rec-table-wrap,
[class$="-table-wrap"],
[class$="-scroll"] {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  /* position relative biar tidak di-clip oleh parent overflow:hidden */
  position: relative;
}

.table-scroll::-webkit-scrollbar,
.income-table-wrap::-webkit-scrollbar,
.expense-table-wrap::-webkit-scrollbar,
.rec-table-wrap::-webkit-scrollbar,
[class$="-table-wrap"]::-webkit-scrollbar,
[class$="-scroll"]::-webkit-scrollbar {
  display: none;
}

/* ── Pagination footer: tetap menyamping di mobile ── */
@media (max-width: 900px) {
  [class$="-footer"],
  [class*="-footer "] {
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 8px !important;
  }

  [class$="-footer"] > div,
  [class*="-footer "] > div {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 6px !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-shrink: 0;
  }

  [class$="-footer"] > div::-webkit-scrollbar,
  [class*="-footer "] > div::-webkit-scrollbar {
    display: none;
  }
}

@media (max-width: 1280px) {
  .metric-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-grid,
  .lower-grid,
  .bottom-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .admin-app {
    grid-template-columns: 1fr;
    background: var(--bg);
  }

  /* Sidebar hidden by default on mobile */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    width: 270px;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    transform: translateX(-100%);
    transition: transform .26s cubic-bezier(.4,0,.2,1);
    box-shadow: 4px 0 32px rgba(0,0,0,.28);
  }

  .sidebar.sidebar-open {
    transform: translateX(0);
  }

  /* side-nav dan logout sudah dihandle di global CSS */

  .side-nav p {
    grid-column: unset;
  }

  /* Overlay behind sidebar */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 49;
    background: rgba(2, 14, 12, 0.55);
    backdrop-filter: blur(2px);
  }

  .sidebar-overlay.active {
    display: block;
  }
}

/* Hamburger toggle — hidden by default, shown via JS di mobile */
.sidebar-toggle {
  display: none;
}

@media (max-width: 900px) {
  /* Hamburger button — top-left */
  .sidebar-toggle {
    display: grid;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 48;
    place-items: center;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 10px;
    color: #fff;
    background: linear-gradient(135deg, #0f9f63, #076e44);
    box-shadow: 0 4px 14px rgba(7, 139, 85, 0.35);
    cursor: pointer;
  }

  .sidebar-toggle svg {
    width: 22px;
    height: 22px;
  }

  .side-nav p {
    grid-column: unset;
  }

  .content {
    grid-column: 1;
    padding: 72px 14px 24px;
    overflow-x: clip;
  }

  .top-admin {
    grid-template-columns: 40px 1fr;
  }

  .top-admin select,
  .bell,
  .top-profile {
    grid-column: 1 / -1;
  }

  /* Semua grid yang lebar → scroll horizontal, scrollbar disembunyikan */
  .metric-grid,
  .dashboard-grid,
  .lower-grid,
  .bottom-grid,
  .finance > div,
  .quick-panel > div {
    grid-template-columns: 1fr;
  }

  /* Tabel & chart bisa scroll horizontal, scrollbar disembunyikan */
  .table-scroll,
  .line-chart,
  .donut-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .table-scroll::-webkit-scrollbar,
  .line-chart::-webkit-scrollbar,
  .donut-wrap::-webkit-scrollbar {
    display: none;
  }

  /* Panel wrapper yang bisa jadi overflow */
  .panel,
  .metric-grid article {
    min-width: 0;
    overflow: hidden;
  }

  /* Best products & low stock list bisa scroll */
  .best-products,
  .low-stock,
  .customers {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .best-products::-webkit-scrollbar,
  .low-stock::-webkit-scrollbar,
  .customers::-webkit-scrollbar {
    display: none;
  }

  /* List item jangan terlalu kecil */
  .best-products li,
  .low-stock li {
    min-width: 260px;
  }

  /* Donut chart wrap */
  .donut-wrap {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .donut {
    width: 180px;
    height: 180px;
    margin: 0 auto;
  }
}
