:root {
  --green: #0f5132;
  --green-2: #147347;
  --mint: #dff5e9;
  --ink: #14231c;
  --muted: #66746d;
  --line: #dbe5df;
  --bg: #f4f7f5;
  --panel: #ffffff;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(19, 42, 32, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select { font: inherit; }
button { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; padding: 10px 14px; cursor: pointer; }
button:hover { border-color: var(--green); }
.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 700; }
.hidden { display: none !important; }

.auth-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 440px;
  gap: 32px;
  align-items: center;
  padding: 42px;
}

.brand-panel {
  min-height: 620px;
  border-radius: 24px;
  padding: 52px;
  background:
    linear-gradient(135deg, rgba(15, 81, 50, 0.92), rgba(14, 105, 64, 0.82)),
    radial-gradient(circle at 72% 20%, rgba(255,255,255,0.24), transparent 34%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: var(--shadow);
}
.brand-panel h1 { font-size: 54px; margin: 22px 0 12px; letter-spacing: 0; }
.brand-panel p { max-width: 620px; color: rgba(255,255,255,0.84); font-size: 19px; line-height: 1.6; }

.logo-mark {
  width: 94px;
  height: 94px;
  border-radius: 26px;
  background: #fff;
  color: var(--green);
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 54px;
  box-shadow: inset 0 -10px 0 rgba(15, 81, 50, 0.08);
}
.logo-mark.small { width: 42px; height: 42px; border-radius: 12px; font-size: 24px; }

.status-strip {
  margin-top: 44px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: rgba(255,255,255,0.9);
}
.status-strip span { border: 1px solid rgba(255,255,255,0.28); border-radius: 999px; padding: 8px 12px; }

.auth-card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.auth-card { padding: 24px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; }
.tab.active { background: var(--mint); border-color: var(--green); color: var(--green); font-weight: 800; }

.form-stack { display: grid; gap: 14px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
}
input:focus, select:focus { outline: 2px solid rgba(20, 115, 71, 0.16); border-color: var(--green); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.message { min-height: 22px; color: var(--danger); font-weight: 700; }
.api-settings { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.api-settings summary { cursor: pointer; color: var(--green); font-weight: 800; margin-bottom: 12px; }

.main-view { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.sidebar-brand { display: flex; gap: 12px; align-items: center; }
.sidebar-brand small { display: block; color: var(--muted); margin-top: 2px; }
.nav { display: grid; gap: 6px; }
.nav button { text-align: left; border: 0; background: transparent; color: var(--green); font-weight: 700; font-size: 14px; padding: 11px 12px; }
.nav button.active { background: var(--mint); color: var(--green); }
.support { margin-top: auto; font-size: 11px; color: var(--muted); line-height: 1.5; border-top: 1px solid var(--line); padding-top: 14px; }

.content { min-width: 0; padding: 20px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.topbar h2 { margin: 0; font-size: 28px; letter-spacing: 0; }
.topbar small { color: var(--muted); }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge { border-radius: 999px; padding: 8px 12px; background: var(--mint); color: var(--green); font-weight: 800; font-size: 12px; }
.badge.offline { background: #fff1f0; color: var(--danger); }
.icon-button { width: 42px; height: 42px; display: none; padding: 10px; }
.icon-button span { display: block; height: 2px; background: var(--green); margin: 5px 0; }

.page { display: none; }
.page.active { display: grid; gap: 18px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 14px; }
.metric-grid.small { grid-template-columns: repeat(3, minmax(160px, 1fr)); }
.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.metric span { color: var(--muted); font-size: 13px; font-weight: 800; }
.metric strong { display: block; margin-top: 8px; font-size: 30px; color: var(--green); }
.split { display: grid; grid-template-columns: minmax(320px, 0.8fr) minmax(420px, 1.2fr); gap: 18px; align-items: start; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-head h3, .panel h3 { margin: 0; letter-spacing: 0; }
.search { max-width: 360px; }

.sale-layout { display: grid; grid-template-columns: minmax(420px, 1fr) minmax(360px, 0.55fr); gap: 18px; align-items: start; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; max-height: calc(100vh - 180px); overflow: auto; padding-right: 4px; }
.product-tile { text-align: left; padding: 14px; min-height: 120px; }
.product-tile strong { display: block; margin-bottom: 8px; }
.product-tile small { color: var(--muted); display: block; line-height: 1.5; }
.cart-panel { position: sticky; top: 20px; }
.cart-items { display: grid; gap: 10px; max-height: 46vh; overflow: auto; }
.cart-row { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; gap: 8px; }
.cart-row header { display: flex; justify-content: space-between; gap: 12px; }
.qty-controls { display: grid; grid-template-columns: 34px 1fr 34px; gap: 6px; align-items: center; }
.qty-controls button { padding: 6px; }
.totals { display: grid; gap: 10px; margin: 16px 0; border-top: 1px solid var(--line); padding-top: 14px; }
.totals > div { display: flex; justify-content: space-between; }
.totals .grand { font-size: 22px; color: var(--green); }

.table-wrap { overflow: auto; max-height: 62vh; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 11px 8px; font-size: 14px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0; }
.timeline, .list { display: grid; gap: 10px; max-height: 380px; overflow: auto; }
.log-item, .list-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fff; }
.log-item small, .list-item small { color: var(--muted); display: block; margin-top: 4px; }
.narrow { max-width: 540px; }

.receipt { font-family: "Courier New", monospace; width: 280px; padding: 16px; color: #000; }
.receipt h2 { text-align: center; margin: 0 0 8px; }
.receipt-total { font-weight: 900; border-top: 1px dashed #000; padding-top: 8px; }

@media print {
  body * { visibility: hidden; }
  .receipt, .receipt * { visibility: visible; }
  .receipt { position: absolute; left: 0; top: 0; }
}

@media (max-width: 960px) {
  .auth-view { grid-template-columns: 1fr; padding: 18px; }
  .brand-panel { min-height: auto; padding: 28px; }
  .brand-panel h1 { font-size: 38px; }
  .main-view { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; width: min(78vw, 280px); transform: translateX(-100%); transition: transform 180ms ease; }
  .sidebar.open { transform: translateX(0); }
  .icon-button { display: block; }
  .metric-grid, .metric-grid.small, .split, .sale-layout { grid-template-columns: 1fr; }
  .cart-panel { position: static; }
  .topbar { align-items: flex-start; }
}
