/* =====================================================================
   365° POS — Design system
   Ink navy chrome, amber ring mark, teal for stock/success states.
   Fonts: Sora (display/numerals) + Inter (UI/body)
   ===================================================================== */

:root{
  --ink:        #14171F;
  --ink-soft:   #1D2130;
  --ink-line:   #2A2F42;
  --paper:      #F3F4F8;
  --surface:    #FFFFFF;
  --accent:     #FF6B35;
  --accent-dark:#E0551F;
  --accent-soft:#FFE7DB;
  --teal:       #00B39B;
  --teal-soft:  #DFF7F3;
  --teal-dark:  #00806E;
  --line:       #E4E6ED;
  --text:       #1A1D29;
  --text-muted: #6B7280;
  --text-faint: #9AA0AC;
  --danger:     #E5484D;
  --danger-soft:#FDE4E4;
  --warning:    #C9820A;
  --warning-soft:#FCF0D9;
  --radius-sm:  8px;
  --radius:     12px;
  --radius-lg:  18px;
  --shadow-sm:  0 1px 2px rgba(20,23,31,.06), 0 1px 1px rgba(20,23,31,.04);
  --shadow-md:  0 6px 20px rgba(20,23,31,.10);
  --shadow-lg:  0 20px 48px rgba(20,23,31,.22);
  --sidebar-w:  240px;
  --topbar-h:   64px;
}

*,*::before,*::after{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background:var(--paper);
  color:var(--text);
  font-family:'Inter',system-ui,-apple-system,sans-serif;
  -webkit-font-smoothing:antialiased;
  font-variant-numeric: tabular-nums;
}
h1,h2,h3,h4,.brand-text,.num{ font-family:'Sora',system-ui,sans-serif; }
a{ color:inherit; text-decoration:none; }
button{ font-family:inherit; }
ul{ list-style:none; margin:0; padding:0; }
input,select,textarea{ font-family:inherit; font-size:14px; }
svg{ width:100%; height:100%; fill:none; stroke:currentColor; stroke-width:1.9; stroke-linecap:round; stroke-linejoin:round; }
::selection{ background:var(--accent-soft); }
:focus-visible{ outline:2.5px solid var(--accent); outline-offset:2px; }

/* ---------- Brand mark (365° ring) ---------- */
.brand-mark{ width:38px; height:38px; flex:none; color:#fff; }
.brand-mark svg{ overflow:visible; }
.ring-track{ fill:none; stroke:rgba(255,255,255,.16); stroke-width:3.4; }
.ring-arc{ fill:none; stroke:var(--accent); stroke-width:3.4; stroke-linecap:round; }
.ring-deg{ font-family:'Sora',sans-serif; font-weight:700; font-size:11.5px; fill:#fff; stroke:none; letter-spacing:-.3px; }
.brand-mark-lg{ width:84px; height:84px; }
.brand-mark-lg .ring-deg{ font-size:11px; }
.spin-in{ animation:ringSpin .9s cubic-bezier(.2,.8,.2,1) both; }
@keyframes ringSpin{ from{ transform:rotate(-70deg) scale(.75); opacity:0; } to{ transform:rotate(0) scale(1); opacity:1; } }
@media (prefers-reduced-motion:reduce){ .spin-in{ animation:none; } }

/* ---------- App shell ---------- */
.app-shell{ display:flex; min-height:100vh; }

.sidebar{
  width:var(--sidebar-w); flex:none; background:var(--ink); color:#C7CAD9;
  display:flex; flex-direction:column; padding:18px 14px 14px;
  position:fixed; top:0; left:0; bottom:0; z-index:40; overflow-y:auto;
}
.brand{ display:flex; align-items:center; gap:10px; padding:6px 8px 20px; }
.brand-text{ font-size:16px; font-weight:700; color:#fff; line-height:1.15; display:flex; flex-direction:column; }
.brand-text small{ font-family:'Inter',sans-serif; font-weight:500; font-size:10.5px; color:#8B90A6; letter-spacing:.02em; }

.nav-group{ display:flex; flex-direction:column; margin-bottom:14px; }
.nav-label{ font-size:10.5px; font-weight:600; letter-spacing:.09em; text-transform:uppercase; color:#666B82; padding:10px 12px 6px; }
.nav-item{
  display:flex; align-items:center; gap:11px; padding:9px 12px; border-radius:10px;
  font-size:13.5px; font-weight:500; color:#C7CAD9; transition:background .15s,color .15s;
}
.nav-item svg{ width:18px; height:18px; flex:none; stroke-width:1.9; }
.nav-item:hover{ background:var(--ink-soft); color:#fff; }
.nav-item.active{ background:var(--accent); color:#fff; }
.sidebar-footer{ margin-top:auto; padding-top:10px; border-top:1px solid var(--ink-line); }
.logout-link:hover{ background:var(--danger); color:#fff; }
.sidebar-overlay{ display:none; }

.main-area{ flex:1; margin-left:var(--sidebar-w); display:flex; flex-direction:column; min-height:100vh; min-width:0; }

.topbar{
  height:var(--topbar-h); flex:none; background:var(--surface); border-bottom:1px solid var(--line);
  display:flex; align-items:center; gap:14px; padding:0 22px; position:sticky; top:0; z-index:20;
}
.topbar-title{ font-size:18px; font-weight:700; margin:0; }
.topbar-right{ margin-left:auto; display:flex; align-items:center; gap:18px; }
.nav-toggle{ display:none; }

.net-status{ display:flex; align-items:center; gap:6px; font-size:12px; font-weight:600; color:var(--teal-dark); }
.net-status .dot{ width:7px; height:7px; border-radius:50%; background:var(--teal); box-shadow:0 0 0 3px var(--teal-soft); }
.net-status.offline{ color:var(--danger); }
.net-status.offline .dot{ background:var(--danger); box-shadow:0 0 0 3px var(--danger-soft); }

.topbar-clock{ font-size:12.5px; color:var(--text-muted); font-variant-numeric:tabular-nums; white-space:nowrap; }
.topbar-user{ display:flex; align-items:center; gap:9px; }
.avatar{ width:32px; height:32px; border-radius:50%; background:var(--ink); color:#fff; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:13px; font-family:'Sora',sans-serif; }
.topbar-user-info{ display:flex; flex-direction:column; line-height:1.2; }
.topbar-user-info .name{ font-size:13px; font-weight:600; }
.topbar-user-info .role{ font-size:11px; color:var(--text-muted); text-transform:capitalize; }

.page-content{ flex:1; padding:24px; min-width:0; }
.page-content.flush{ padding:0; display:flex; min-height:calc(100vh - var(--topbar-h)); }

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  padding:10px 18px; border-radius:10px; border:1px solid transparent;
  font-size:13.5px; font-weight:600; cursor:pointer; transition:transform .08s,filter .15s,background .15s;
  background:var(--surface); color:var(--text); border-color:var(--line);
}
.btn:hover{ filter:brightness(0.97); }
.btn:active{ transform:scale(.98); }
.btn:disabled{ opacity:.55; cursor:not-allowed; }
.btn svg{ width:16px; height:16px; }
.btn-primary{ background:var(--accent); border-color:var(--accent); color:#fff; }
.btn-primary:hover{ background:var(--accent-dark); border-color:var(--accent-dark); }
.btn-dark{ background:var(--ink); border-color:var(--ink); color:#fff; }
.btn-teal{ background:var(--teal); border-color:var(--teal); color:#fff; }
.btn-outline{ background:transparent; border-color:var(--line); color:var(--text); }
.btn-danger{ background:var(--danger-soft); border-color:var(--danger-soft); color:var(--danger); }
.btn-danger:hover{ background:var(--danger); color:#fff; }
.btn-sm{ padding:6px 12px; font-size:12.5px; border-radius:8px; }
.btn-lg{ padding:14px 22px; font-size:15px; border-radius:12px; }
.btn-block{ width:100%; }
.icon-btn{ width:36px; height:36px; border-radius:9px; border:1px solid var(--line); background:var(--surface); display:flex; align-items:center; justify-content:center; cursor:pointer; color:var(--text); flex:none; }
.icon-btn svg{ width:17px; height:17px; }
.icon-btn:hover{ background:var(--paper); }
.icon-btn.danger:hover{ background:var(--danger-soft); color:var(--danger); border-color:var(--danger-soft); }

/* ---------- Cards / stats ---------- */
.card{ background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:18px; }
.card-title{ font-size:14px; font-weight:700; margin:0 0 14px; display:flex; align-items:center; justify-content:space-between; }
.stat-grid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); gap:14px; margin-bottom:20px; }
.stat-card{ background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:16px 18px; display:flex; align-items:center; gap:14px; }
.stat-icon{ width:42px; height:42px; border-radius:11px; display:flex; align-items:center; justify-content:center; flex:none; }
.stat-icon svg{ width:20px; height:20px; }
.stat-icon.accent{ background:var(--accent-soft); color:var(--accent-dark); }
.stat-icon.teal{ background:var(--teal-soft); color:var(--teal-dark); }
.stat-icon.ink{ background:#E7E8ED; color:var(--ink); }
.stat-icon.warn{ background:var(--warning-soft); color:var(--warning); }
.stat-value{ font-size:22px; font-weight:800; line-height:1.1; }
.stat-label{ font-size:12px; color:var(--text-muted); margin-top:2px; }

.section-head{ display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:16px; flex-wrap:wrap; }
.section-head h2{ font-size:17px; margin:0; }
.toolbar{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }

/* ---------- Forms ---------- */
.field{ display:flex; flex-direction:column; gap:6px; margin-bottom:14px; }
.field span{ font-size:12.5px; font-weight:600; color:var(--text-muted); }
.field input,.field select,.field textarea{
  padding:10px 12px; border:1px solid var(--line); border-radius:9px; background:var(--surface); color:var(--text);
  transition:border-color .15s, box-shadow .15s;
}
.field input:focus,.field select:focus,.field textarea:focus{ border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-soft); outline:none; }
.field-row{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.search-box{ position:relative; }
.search-box svg{ position:absolute; left:11px; top:50%; transform:translateY(-50%); width:16px; height:16px; color:var(--text-faint); }
.search-box input{ padding-left:34px; min-width:220px; }

.alert{ padding:11px 14px; border-radius:9px; font-size:13px; font-weight:500; margin-bottom:14px; }
.alert-danger{ background:var(--danger-soft); color:var(--danger); }
.alert-success{ background:var(--teal-soft); color:var(--teal-dark); }
.alert-warn{ background:var(--warning-soft); color:var(--warning); }

/* ---------- Tables ---------- */
.table-wrap{ background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); overflow:hidden; }
table{ width:100%; border-collapse:collapse; font-size:13.5px; }
thead th{ text-align:left; font-size:11.5px; text-transform:uppercase; letter-spacing:.04em; color:var(--text-muted); padding:12px 16px; background:var(--paper); border-bottom:1px solid var(--line); font-weight:600; }
tbody td{ padding:12px 16px; border-bottom:1px solid var(--line); vertical-align:middle; }
tbody tr:last-child td{ border-bottom:none; }
tbody tr:hover{ background:#FAFAFC; }
.table-scroll{ overflow-x:auto; }
.empty-row td{ text-align:center; padding:40px 16px; color:var(--text-faint); }

.badge{ display:inline-flex; align-items:center; padding:3px 9px; border-radius:99px; font-size:11px; font-weight:700; letter-spacing:.02em; }
.badge-teal{ background:var(--teal-soft); color:var(--teal-dark); }
.badge-warn{ background:var(--warning-soft); color:var(--warning); }
.badge-danger{ background:var(--danger-soft); color:var(--danger); }
.badge-ink{ background:#E7E8ED; color:var(--ink); }
.badge-accent{ background:var(--accent-soft); color:var(--accent-dark); }

.pagination{ display:flex; align-items:center; justify-content:space-between; padding:12px 16px; font-size:12.5px; color:var(--text-muted); }

/* ---------- Modal ---------- */
.modal-overlay{
  position:fixed; inset:0; background:rgba(15,17,25,.55); display:none; align-items:center; justify-content:center;
  padding:20px; z-index:100;
}
.modal-overlay.open{ display:flex; }
.modal{ background:var(--surface); border-radius:var(--radius-lg); width:100%; max-width:520px; max-height:90vh; display:flex; flex-direction:column; box-shadow:var(--shadow-lg); }
.modal.modal-wide{ max-width:760px; }
.modal-head{ display:flex; align-items:center; justify-content:space-between; padding:18px 22px; border-bottom:1px solid var(--line); }
.modal-head h3{ margin:0; font-size:16px; }
.modal-body{ padding:20px 22px; overflow-y:auto; }
.modal-foot{ padding:16px 22px; border-top:1px solid var(--line); display:flex; justify-content:flex-end; gap:10px; }

/* ---------- Toasts ---------- */
.toast-stack{ position:fixed; bottom:20px; right:20px; z-index:200; display:flex; flex-direction:column; gap:10px; }
.toast{ background:var(--ink); color:#fff; padding:12px 16px; border-radius:10px; font-size:13px; font-weight:500; box-shadow:var(--shadow-md); display:flex; align-items:center; gap:10px; min-width:220px; animation:toastIn .2s ease; }
.toast.success{ background:var(--teal-dark); }
.toast.error{ background:var(--danger); }
@keyframes toastIn{ from{ opacity:0; transform:translateY(8px); } to{ opacity:1; transform:translateY(0); } }

/* ---------- Login page ---------- */
.login-body{ margin:0; min-height:100vh; background:radial-gradient(circle at 20% 0%, #23283C 0%, var(--ink) 55%); display:flex; align-items:center; justify-content:center; padding:24px; }
.login-wrap{ width:100%; max-width:400px; display:flex; flex-direction:column; align-items:center; }
.login-brand{ text-align:center; margin-bottom:22px; color:#fff; }
.login-brand h1{ font-size:24px; margin:14px 0 4px; }
.login-brand p{ margin:0; color:#9AA0BE; font-size:13px; }
.login-card{ background:var(--surface); border-radius:var(--radius-lg); padding:26px 24px; width:100%; box-shadow:var(--shadow-lg); }
.login-card h2{ font-size:16px; margin:0 0 16px; }
.pw-wrap{ position:relative; }
.pw-wrap input{ width:100%; padding-right:40px; }
.pw-toggle{ position:absolute; right:8px; top:50%; transform:translateY(-50%); background:none; border:none; width:28px; height:28px; color:var(--text-faint); cursor:pointer; }
.login-hint{ text-align:center; font-size:11.5px; color:var(--text-faint); margin-top:14px; }
.login-footer{ color:#6D7290; font-size:11.5px; margin-top:18px; text-align:center; }
.field input{ width:100%; }

/* ---------- POS layout ---------- */
.pos-layout{ display:flex; width:100%; min-width:0; }
.pos-products{ flex:1; min-width:0; padding:18px 20px; overflow-y:auto; }
.pos-cart{ width:380px; flex:none; background:var(--surface); border-left:1px solid var(--line); display:flex; flex-direction:column; height:calc(100vh - var(--topbar-h)); position:sticky; top:var(--topbar-h); }

.scan-bar{ display:flex; gap:10px; margin-bottom:14px; }
.scan-bar .search-box{ flex:1; }
.scan-bar input{ width:100%; padding:12px 12px 12px 34px; font-size:14.5px; border-radius:10px; }

.category-tabs{ display:flex; gap:8px; overflow-x:auto; padding-bottom:10px; margin-bottom:6px; }
.category-tabs::-webkit-scrollbar{ height:0; }
.cat-tab{ flex:none; padding:8px 15px; border-radius:99px; background:var(--surface); border:1px solid var(--line); font-size:12.5px; font-weight:600; color:var(--text-muted); cursor:pointer; white-space:nowrap; }
.cat-tab.active{ background:var(--ink); border-color:var(--ink); color:#fff; }

.product-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(136px,1fr)); gap:12px; }
.product-card{ background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:12px; cursor:pointer; text-align:left; display:flex; flex-direction:column; gap:8px; transition:border-color .12s, transform .08s; position:relative; }
.product-card:hover{ border-color:var(--accent); }
.product-card:active{ transform:scale(.97); }
.product-thumb{ width:100%; aspect-ratio:1/1; border-radius:9px; background:var(--paper); display:flex; align-items:center; justify-content:center; color:var(--text-faint); font-size:22px; font-weight:800; overflow:hidden; }
.product-thumb img{ width:100%; height:100%; object-fit:cover; }
.product-name{ font-size:12.5px; font-weight:600; line-height:1.3; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; min-height:2.4em; }
.product-price{ font-family:'Sora',sans-serif; font-weight:700; font-size:14px; color:var(--accent-dark); }
.product-stock-flag{ position:absolute; top:8px; right:8px; font-size:9.5px; font-weight:700; padding:2px 6px; border-radius:99px; }
.product-card.out-of-stock{ opacity:.45; pointer-events:none; }

.cart-head{ padding:16px 18px 10px; display:flex; align-items:center; justify-content:space-between; border-bottom:1px solid var(--line); }
.cart-head h3{ margin:0; font-size:14.5px; }
.cart-items{ flex:1; overflow-y:auto; padding:8px 14px; }
.cart-empty{ text-align:center; color:var(--text-faint); padding:50px 16px; font-size:13px; }
.cart-item{ display:flex; align-items:center; gap:10px; padding:10px 4px; border-bottom:1px solid var(--line); }
.cart-item:last-child{ border-bottom:none; }
.cart-item-info{ flex:1; min-width:0; }
.cart-item-name{ font-size:12.8px; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.cart-item-price{ font-size:11.5px; color:var(--text-muted); }
.qty-stepper{ display:flex; align-items:center; border:1px solid var(--line); border-radius:8px; flex:none; }
.qty-stepper button{ width:24px; height:24px; border:none; background:none; cursor:pointer; font-size:14px; color:var(--text); }
.qty-stepper span{ width:24px; text-align:center; font-size:12.5px; font-weight:700; }
.cart-item-total{ width:60px; text-align:right; font-size:12.8px; font-weight:700; font-family:'Sora',sans-serif; }
.cart-item-remove{ width:22px; height:22px; flex:none; border:none; background:none; color:var(--text-faint); cursor:pointer; }
.cart-item-remove:hover{ color:var(--danger); }

.cart-summary{ padding:14px 18px; border-top:1px solid var(--line); }
.summary-row{ display:flex; justify-content:space-between; font-size:12.8px; color:var(--text-muted); margin-bottom:7px; }
.summary-row.total{ font-size:17px; font-weight:800; color:var(--text); margin-top:10px; padding-top:10px; border-top:1px dashed var(--line); }
.summary-row input{ width:80px; text-align:right; padding:4px 8px; border-radius:6px; }
.pay-methods{ display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin:12px 0; }
.pay-method{ padding:10px 4px; text-align:center; border:1px solid var(--line); border-radius:9px; font-size:12px; font-weight:700; cursor:pointer; color:var(--text-muted); }
.pay-method.active{ background:var(--ink); color:#fff; border-color:var(--ink); }
.pay-actions{ display:flex; gap:8px; }
.pay-actions .btn{ flex:1; }

/* ---------- Receipt (print) ---------- */
.receipt{ display:none; }
.receipt-view{ font-family:'Inter',monospace; font-size:12.5px; width:280px; margin:0 auto; color:#000; }
.receipt-view h2{ text-align:center; font-size:15px; margin:0 0 2px; }
.receipt-view .center{ text-align:center; }
.receipt-view hr{ border:none; border-top:1px dashed #000; margin:8px 0; }
.receipt-view table{ font-size:11.5px; }
.receipt-view thead th{ background:none; padding:2px 0; border:none; }
.receipt-view tbody td{ padding:2px 0; border:none; }
.receipt-total-row td{ font-weight:700; }

/* ---------- Login-style empty/loading states ---------- */
.loading-row{ text-align:center; padding:30px; color:var(--text-faint); font-size:13px; }
.muted{ color:var(--text-muted); }
.flex{ display:flex; align-items:center; }
.gap-8{ gap:8px; }
.mt-0{ margin-top:0; }
.text-right{ text-align:right; }
.filter-bar{ display:flex; gap:10px; flex-wrap:wrap; margin-bottom:16px; align-items:center; }
.filter-bar input,.filter-bar select{ padding:9px 12px; border:1px solid var(--line); border-radius:9px; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px){
  .pos-cart{ width:320px; }
}

@media (max-width: 900px){
  .sidebar{ transform:translateX(-100%); transition:transform .2s ease; box-shadow:var(--shadow-lg); }
  .sidebar.open{ transform:translateX(0); }
  .main-area{ margin-left:0; }
  .nav-toggle{ display:flex; }
  .sidebar-overlay{ display:none; position:fixed; inset:0; background:rgba(15,17,25,.5); z-index:39; }
  .sidebar-overlay.open{ display:block; }
  .pos-layout{ flex-direction:column; }
  .pos-cart{ width:100%; height:auto; position:relative; top:0; border-left:none; border-top:1px solid var(--line); }
  .topbar-clock{ display:none; }
  .stat-grid{ grid-template-columns:repeat(2,1fr); }
  .field-row{ grid-template-columns:1fr; }
}

@media (max-width: 520px){
  .page-content{ padding:16px; }
  .stat-grid{ grid-template-columns:1fr 1fr; gap:10px; }
  .topbar{ padding:0 14px; }
  .topbar-user-info{ display:none; }
  .product-grid{ grid-template-columns:repeat(auto-fill,minmax(112px,1fr)); }
}

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