@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Thai:wght@300;400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

/* ══════════════════════════════════════════════
   DESIGN TOKENS
══════════════════════════════════════════════ */
:root {
  --navy:      #0D2137;
  --navy-m:    #162E48;
  --navy-l:    #1E3D5A;
  --primary:   #1B72BB;
  --primary-m: #2882CF;
  --primary-l: #5BA8E2;
  --primary-xl:#EBF5FF;
  --accent:    #00B4D8;

  --bg:        #F0F4F8;
  --surface:   #FFFFFF;
  --border:    #E2EBF3;
  --border-l:  #F0F4F8;

  --text:      #0D1F30;
  --text-m:    #4D6A84;
  --text-l:    #8FADC6;

  --green:     #059669; --green-bg: #ECFDF5; --green-b: #6EE7B7;
  --amber:     #D97706; --amber-bg: #FFFBEB; --amber-b: #FCD34D;
  --red:       #DC2626; --red-bg:   #FEF2F2; --red-b:   #FCA5A5;

  --sh-xs: 0 1px 2px rgba(13,33,55,.05);
  --sh-sm: 0 1px 4px rgba(13,33,55,.08), 0 1px 2px rgba(13,33,55,.04);
  --sh:    0 4px 12px rgba(13,33,55,.08), 0 2px 4px rgba(13,33,55,.04);
  --sh-md: 0 8px 24px rgba(13,33,55,.10), 0 4px 8px rgba(13,33,55,.06);
  --sh-lg: 0 20px 40px rgba(13,33,55,.12), 0 8px 16px rgba(13,33,55,.06);

  --r-xs: 6px; --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 20px; --r-2xl: 28px;
}

/* ══════════════════════════════════════════════
   RESET & BASE
══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body {
  font-family: 'IBM Plex Sans Thai', 'Inter', system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; min-height: 100dvh; line-height: 1.5;
  overflow-x: hidden;
}

/* ══════════════════════════════════════════════
   LOGIN — SPLIT SCREEN
══════════════════════════════════════════════ */
.login-screen {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: stretch;
}

/* Left brand panel */
.login-brand {
  flex: 1; display: flex; flex-direction: column;
  justify-content: center; align-items: flex-start;
  padding: 60px 56px;
  background: linear-gradient(145deg, var(--navy) 0%, var(--navy-l) 60%, #1B6BAD 100%);
  position: relative; overflow: hidden;
}
.login-brand::before {
  content: ''; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.login-brand::after {
  content: ''; position: absolute;
  width: 400px; height: 400px; border-radius: 50%;
  background: radial-gradient(circle, rgba(27,114,187,.25) 0%, transparent 70%);
  right: -100px; bottom: -100px; pointer-events: none;
}
.login-brand-circle {
  position: absolute; border-radius: 50%; border: 1px solid rgba(255,255,255,.08);
}
.login-brand-circle:nth-child(1) { width: 300px; height: 300px; top: -80px; right: -80px; }
.login-brand-circle:nth-child(2) { width: 500px; height: 500px; top: -180px; right: -180px; opacity: .5; }

.login-brand-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 52px; position: relative; }
.login-brand-logo img { height: 52px; filter: brightness(0) invert(1); }
.login-brand-name { font-size: 20px; font-weight: 700; color: #fff; letter-spacing: -.2px; }

.login-brand-title {
  font-size: 40px; font-weight: 700; color: #fff; line-height: 1.2;
  letter-spacing: -.8px; position: relative;
}

/* Right form panel */
.login-form-panel {
  width: 440px; flex-shrink: 0;
  display: flex; flex-direction: column; justify-content: center;
  padding: 60px 48px; background: var(--surface);
  box-shadow: -20px 0 60px rgba(13,33,55,.15);
  overflow-y: auto;
}
.login-form-header { margin-bottom: 36px; }
.login-form-title { font-size: 26px; font-weight: 700; color: var(--text); letter-spacing: -.3px; }
.login-form-sub   { font-size: 14px; color: var(--text-m); margin-top: 6px; }

.login-field { margin-bottom: 18px; }
.login-field label {
  display: block; font-size: 12px; font-weight: 600; color: var(--text-m);
  text-transform: uppercase; letter-spacing: .6px; margin-bottom: 8px;
}
.login-input-wrap { position: relative; }
.login-input-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-l); pointer-events: none;
}
.login-field input {
  width: 100%; font-family: inherit; font-size: 14.5px;
  padding: 12px 14px 12px 44px;
  border: 1.5px solid var(--border); border-radius: var(--r);
  background: var(--bg); color: var(--text); outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.login-field input:focus {
  border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 4px rgba(27,114,187,.10);
}
.login-err { min-height: 18px; font-size: 12.5px; color: var(--red); font-weight: 500; margin-bottom: 18px; }
.login-btn {
  width: 100%; padding: 14px; font-size: 14.5px; font-weight: 700;
  font-family: inherit;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-m) 100%);
  color: #fff; border: none; border-radius: var(--r); cursor: pointer;
  box-shadow: 0 4px 14px rgba(27,114,187,.40);
  transition: opacity .15s, transform .1s, box-shadow .15s; letter-spacing: .2px;
}
.login-btn:hover  { opacity: .93; box-shadow: 0 6px 18px rgba(27,114,187,.48); }
.login-btn:active { transform: scale(.98); }
.login-btn:disabled { opacity: .55; cursor: not-allowed; }
.login-footer-text { margin-top: 24px; font-size: 11.5px; color: var(--text-l); text-align: center; }
.login-card.shake { animation: shake .4s ease; }
@keyframes shake {
  0%,100%{transform:none} 20%{transform:translateX(-8px)} 40%{transform:translateX(8px)}
  60%{transform:translateX(-5px)} 80%{transform:translateX(5px)}
}

/* Mobile logo — shown only on mobile */
.login-mobile-logo {
  display: none; align-items: center; gap: 10px;
  margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--border);
}
.login-mobile-logo img { height: 36px; }
.login-mobile-logo span { font-size: 16px; font-weight: 700; color: var(--primary); }

/* ══════════════════════════════════════════════
   HEADER
══════════════════════════════════════════════ */
.app-header {
  position: sticky; top: 0; z-index: 40; height: 64px;
  background: var(--navy); border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; gap: 16px;
  box-shadow: 0 2px 12px rgba(13,33,55,.25);
}
.header-brand { display: flex; align-items: center; gap: 12px; }
.logo-img     { height: 34px; width: auto; filter: brightness(0) invert(1); flex-shrink: 0; }
.brand-divider { width: 1px; height: 24px; background: rgba(255,255,255,.15); }
.brand-text   { }
.brand-name   { display: block; font-size: 15px; font-weight: 700; color: #fff; white-space: nowrap; letter-spacing: -.1px; }
.brand-sub    { display: block; font-size: 10px; color: rgba(255,255,255,.45); letter-spacing: .8px; text-transform: uppercase; }
.header-actions { display: flex; align-items: center; gap: 8px; }

/* ══════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════ */
button { font-family: inherit; cursor: pointer; border: none; transition: all .15s; }
button:active { transform: translateY(1px); }

.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px; font-size: 13px; font-weight: 600; border-radius: var(--r-sm); }
.btn-ghost   { background: rgba(255,255,255,.08); color: rgba(255,255,255,.85); border: 1px solid rgba(255,255,255,.12); }
.btn-ghost:hover { background: rgba(255,255,255,.15); color: #fff; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(27,114,187,.35); }
.btn-primary:hover { background: var(--primary-m); box-shadow: 0 4px 12px rgba(27,114,187,.45); }
.btn-label   { display: inline; }

/* User pill */
.user-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px; background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12); border-radius: 999px;
  color: rgba(255,255,255,.85); font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background .15s;
}
.user-pill:hover { background: rgba(255,255,255,.15); }
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
  text-transform: uppercase;
}

/* ══════════════════════════════════════════════
   TAB NAVIGATION
══════════════════════════════════════════════ */
.app-tabs {
  display: flex; background: var(--navy-m);
  border-bottom: 1px solid rgba(255,255,255,.06);
  padding: 0 28px; gap: 2px;
}
.tab-btn {
  padding: 0 18px; height: 44px;
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: rgba(255,255,255,.5);
  background: transparent; border-radius: 0;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tab-btn.active { color: #fff; border-bottom-color: var(--primary-l); }
.tab-btn:hover  { color: rgba(255,255,255,.85); }

/* ══════════════════════════════════════════════
   LAYOUT
══════════════════════════════════════════════ */
.tab-panel { display: block; }
.tab-panel.hidden { display: none; }
.app-main { max-width: 1200px; margin: 0 auto; padding: 28px 28px 100px; }

/* ══════════════════════════════════════════════
   STATS CARDS
══════════════════════════════════════════════ */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 20px 22px; box-shadow: var(--sh-sm); display: flex; align-items: center; gap: 16px;
  transition: box-shadow .2s, transform .15s; border-left: 3px solid var(--primary);
}
.stat-card:hover { box-shadow: var(--sh-md); transform: translateY(-2px); }
.stat-card.warn { border-left-color: var(--amber); }
.stat-card.bad  { border-left-color: var(--red); }
.stat-card.txn  { border-left-color: var(--green); }
.stat-icon {
  width: 44px; height: 44px; border-radius: var(--r); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-xl); color: var(--primary);
}
.stat-card.warn .stat-icon { background: var(--amber-bg); color: var(--amber); }
.stat-card.bad  .stat-icon { background: var(--red-bg);   color: var(--red); }
.stat-card.txn  .stat-icon { background: var(--green-bg); color: var(--green); }
.stat-n { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; letter-spacing: -.5px; }
.stat-l { font-size: 12px; color: var(--text-m); margin-top: 4px; font-weight: 500; }

/* ══════════════════════════════════════════════
   CATEGORY BAR
══════════════════════════════════════════════ */
.cat-filter-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.cat-bar {
  display: flex; gap: 6px; overflow-x: auto; flex: 1; min-width: 0;
  scrollbar-width: none; padding-bottom: 2px;
}
.cat-bar::-webkit-scrollbar { display: none; }
.cat-chip {
  flex-shrink: 0; padding: 7px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--border); color: var(--text-m);
  transition: all .15s;
}
.cat-chip:hover  { border-color: var(--primary-l); color: var(--primary); }
.cat-chip.active { color: #fff; border-color: transparent; }

/* ══════════════════════════════════════════════
   TOOLBAR
══════════════════════════════════════════════ */
.toolbar {
  display: flex; gap: 16px; align-items: center; margin-bottom: 16px;
}

.search-box {
  flex: 1; min-width: 0; position: relative;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 10px;
  display: flex; align-items: center;
  transition: border-color .15s, box-shadow .15s;
}
.search-box:focus-within {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(27,114,187,.10);
}
.search-icon {
  position: absolute; left: 13px; color: var(--text-l);
  pointer-events: none; display: flex; align-items: center;
}
.search-box input {
  border: none; outline: none; background: transparent; font-family: inherit;
  font-size: 14px; width: 100%; height: 100%; color: var(--text);
  padding: 0 34px 0 40px; border-radius: 10px;
}
.search-box input::placeholder { color: var(--text-l); }
.search-clear {
  position: absolute; right: 10px; display: none; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; background: var(--text-l);
  color: #fff; border: none; cursor: pointer; padding: 0; opacity: .65; transition: opacity .15s;
}
.search-clear:hover { opacity: 1; }

.filter-pills {
  display: flex; gap: 3px; flex-shrink: 0;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 10px; padding: 3px; align-items: center;
}
.pill {
  height: 28px; padding: 0 13px; border-radius: 7px;
  font-size: 13px; font-weight: 600; color: var(--text-m);
  background: transparent; border: none;
  transition: all .15s; cursor: pointer; white-space: nowrap;
  display: flex; align-items: center;
}
.pill:hover  { color: var(--text); background: rgba(0,0,0,.04); }
.pill.active {
  background: var(--surface); color: var(--primary);
  box-shadow: 0 1px 4px rgba(0,0,0,.10);
}

.sort-select {
  flex-shrink: 0; height: 40px; padding: 0 12px; width: 150px;
  font-family: inherit; font-size: 13px; font-weight: 500;
  color: var(--text-m); background: var(--surface);
  border: 1.5px solid var(--border); border-radius: 10px;
  cursor: pointer; outline: none; transition: border-color .15s;
}
.sort-select:focus { border-color: var(--primary); }

/* ══════════════════════════════════════════════
   ITEM CARDS
══════════════════════════════════════════════ */
.items-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 14px; }
.item-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  overflow: hidden; box-shadow: var(--sh-sm); display: flex; flex-direction: column;
  transition: box-shadow .2s, transform .15s;
}
.item-card:hover { box-shadow: var(--sh-md); transform: translateY(-3px); }

.item-thumb {
  height: 130px; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative; overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.item-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.item-thumb:hover img { transform: scale(1.05); }
.thumb-placeholder { color: var(--text-l); opacity: .4; }
.thumb-overlay {
  position: absolute; inset: 0; background: rgba(13,33,55,.5);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s; color: #fff; font-size: 12px; font-weight: 600;
  gap: 6px;
}
.item-thumb:hover .thumb-overlay { opacity: 1; }

.cat-dot {
  position: absolute; top: 10px; right: 10px;
  width: 8px; height: 8px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.8); box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

.item-body { padding: 14px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.item-name { font-size: 13px; font-weight: 600; line-height: 1.45; min-height: 2.9em; color: var(--text); }
.item-qty-row { display: flex; align-items: flex-end; justify-content: space-between; }
.item-qty { font-size: 28px; font-weight: 700; line-height: 1; color: var(--primary); letter-spacing: -.5px; }
.item-qty small { font-size: 11px; color: var(--text-m); font-weight: 500; margin-left: 3px; letter-spacing: 0; }
.item-meta { font-size: 11px; color: var(--text-l); font-family: 'Inter', monospace; }
.move-row { display: flex; gap: 7px; }
.move-row button { flex: 1; padding: 8px 6px; font-size: 12.5px; font-weight: 600; border-radius: var(--r-sm); transition: all .15s; }
.btn-in  { background: var(--primary-xl); color: var(--primary); border: 1.5px solid rgba(27,114,187,.2); }
.btn-in:hover  { background: var(--primary); color: #fff; }
.btn-out { background: var(--bg); color: var(--text-m); border: 1.5px solid var(--border); }
.btn-out:hover { background: var(--border); color: var(--text); }

/* ══════════════════════════════════════════════
   BADGES
══════════════════════════════════════════════ */
.badge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; letter-spacing: .2px; }
.badge-ok  { background: var(--green-bg); color: var(--green); }
.badge-low { background: var(--amber-bg); color: var(--amber); }
.badge-bad { background: var(--red-bg);   color: var(--red); }

/* ══════════════════════════════════════════════
   EMPTY / NOTE
══════════════════════════════════════════════ */
.empty-state {
  grid-column: 1/-1; text-align: center; padding: 72px 20px;
  color: var(--text-l); font-size: 14px;
}
.empty-state svg { margin-bottom: 12px; opacity: .2; }
.store-note { font-size: 11.5px; color: var(--text-l); margin-top: 24px; text-align: center; }

/* ══════════════════════════════════════════════
   FAB
══════════════════════════════════════════════ */
.fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 30;
  background: var(--primary); color: #fff; border-radius: var(--r-xl);
  padding: 14px 22px; font-size: 14px; font-weight: 700;
  box-shadow: 0 8px 24px rgba(27,114,187,.45);
  display: flex; align-items: center; gap: 8px;
  transition: all .2s;
}
.fab:hover   { background: var(--primary-m); box-shadow: 0 12px 28px rgba(27,114,187,.55); transform: translateY(-2px); }
.fab:active  { transform: scale(.97); }
.fab-label   { font-weight: 700; }

/* ══════════════════════════════════════════════
   MODALS
══════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50; display: none;
  align-items: flex-end; justify-content: center;
  background: rgba(13,33,55,.55); backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal-sheet {
  background: var(--surface); width: 100%; max-width: 560px;
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  border-top: 1px solid var(--border);
  max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  animation: slideUp .22s cubic-bezier(.22,.61,.36,1);
  box-shadow: 0 -8px 40px rgba(13,33,55,.15);
}
@keyframes slideUp { from{transform:translateY(32px);opacity:.2} to{transform:none;opacity:1} }

.confirm-sheet { max-width: 400px; text-align: center; }
.confirm-icon  { font-size: 44px; margin: 28px 0 8px; }
.confirm-sheet h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.confirm-sheet p  { font-size: 13.5px; color: var(--text-m); }

.modal-header { padding: 22px 24px 16px; border-bottom: 1px solid var(--border); }
.modal-title  { font-size: 18px; font-weight: 700; color: var(--text); letter-spacing: -.2px; }
.modal-sub    { font-size: 12.5px; color: var(--text-m); margin-top: 3px; }
.modal-body   { padding: 20px 24px; }
.modal-footer { display: flex; gap: 10px; padding: 0 24px 24px; }
.modal-footer button { flex: 1; padding: 13px; font-size: 14px; font-weight: 600; border-radius: var(--r); }

/* ══════════════════════════════════════════════
   FORMS
══════════════════════════════════════════════ */
label.field-label {
  display: block; font-size: 11.5px; font-weight: 700;
  color: var(--text-m); margin: 16px 0 6px;
  text-transform: uppercase; letter-spacing: .5px;
}
input[type=text], input[type=number], input[type=date], select {
  width: 100%; font-family: inherit; font-size: 14.5px;
  padding: 10px 13px; border: 1.5px solid var(--border); border-radius: var(--r);
  background: var(--bg); color: var(--text); outline: none; transition: all .15s;
}
input:focus, select:focus {
  border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 3px rgba(27,114,187,.10);
}
.field-row { display: flex; gap: 10px; }
.field-row > div { flex: 1; }

.seg-control {
  display: flex; border: 1.5px solid var(--border); border-radius: var(--r); overflow: hidden; margin-top: 14px;
}
.seg-control button {
  flex: 1; padding: 11px; font-size: 14px; font-weight: 600;
  background: var(--bg); color: var(--text-m); border-radius: 0; border-right: 1px solid var(--border);
}
.seg-control button:last-child { border-right: none; }
.seg-control button.active-in  { background: var(--primary); color: #fff; }
.seg-control button.active-out { background: var(--amber);   color: #fff; }

.edit-thumb {
  height: 140px; background: var(--bg); border: 1.5px dashed var(--border); border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; overflow: hidden; margin-bottom: 4px; transition: all .15s;
}
.edit-thumb:hover { border-color: var(--primary); background: var(--primary-xl); }
.edit-thumb img   { width: 100%; height: 100%; object-fit: cover; }
.edit-thumb-ph    { color: var(--text-l); font-size: 12px; text-align: center; }

.history-section  { margin-top: 18px; border-top: 1px dashed var(--border); padding-top: 14px; }
.history-title    { font-size: 11px; font-weight: 700; color: var(--text-m); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 10px; }
.history-row      { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; padding: 7px 0; border-bottom: 1px solid var(--border-l); }
.history-row:last-child { border-bottom: none; }
.history-meta     { color: var(--text-m); }
.history-qty-in   { color: var(--green); font-weight: 700; }
.history-qty-out  { color: var(--red);   font-weight: 700; }

.btn-delete { background: var(--red-bg); color: var(--red); border: 1.5px solid var(--red-b); display: flex; align-items: center; gap: 6px; padding: 9px 14px; font-size: 13px; font-weight: 600; border-radius: var(--r-sm); }
.btn-delete:hover { background: #FEE2E2; }
.item-editor-actions { display: flex; justify-content: flex-end; margin-top: 14px; }

.btn-save   { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(27,114,187,.30); }
.btn-save:hover { background: var(--primary-m); }
.btn-cancel { background: var(--bg); color: var(--text-m); border: 1.5px solid var(--border); }
.btn-cancel:hover { background: var(--border); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; box-shadow: 0 2px 8px rgba(220,38,38,.30); }
.btn-danger:hover { background: #B91C1C; }

/* ══════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════ */
.toast-container {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; min-width: 300px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: var(--r-lg);
  font-size: 13.5px; font-weight: 600; color: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,.20);
  opacity: 0; transform: translateY(16px) scale(.95);
  transition: opacity .22s, transform .22s;
  pointer-events: auto; max-width: 380px;
}
.toast.toast-show { opacity: 1; transform: translateY(0) scale(1); }
.toast-success { background: #065F46; }
.toast-error   { background: #991B1B; }
.toast-warning { background: #78350F; }
.toast-info    { background: var(--navy); }
.toast-icon    { flex-shrink: 0; }

/* ══════════════════════════════════════════════
   REPORTS
══════════════════════════════════════════════ */
.report-grid-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; margin-bottom: 16px; }
.report-grid-1 { margin-bottom: 16px; }
.report-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 22px; box-shadow: var(--sh-sm);
}
.report-card-title {
  font-size: 13px; font-weight: 700; color: var(--text-m);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 18px;
  display: flex; align-items: center; gap: 8px;
}
.chart-wrap      { position: relative; height: 260px; }
.chart-wrap-tall { position: relative; height: 420px; }

.alert-ok { display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: var(--green-bg); border-radius: var(--r); font-size: 14px; color: var(--green); font-weight: 600; border: 1px solid var(--green-b); }
.alert-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border-l); font-size: 13px; }
.alert-row:last-child { border-bottom: none; }
.alert-name { flex: 1; font-weight: 500; color: var(--text); }
.alert-qty  { font-family: 'Inter', monospace; font-size: 13px; color: var(--text-m); font-weight: 600; }

.txn-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.txn-table th {
  text-align: left; padding: 10px 14px;
  background: var(--bg); color: var(--text-m); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border);
}
.txn-table th:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.txn-table th:last-child  { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.txn-table td { padding: 11px 14px; border-bottom: 1px solid var(--border-l); vertical-align: middle; }
.txn-table tr:last-child td { border-bottom: none; }
.txn-table tr:hover td { background: var(--bg); }
.td-date { font-family: 'Inter', monospace; color: var(--text-m); white-space: nowrap; font-size: 12px; }
.td-name { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 500; }
.td-in   { color: var(--green); font-weight: 700; font-family: 'Inter', monospace; }
.td-out  { color: var(--red);   font-weight: 700; font-family: 'Inter', monospace; }
.td-who  { color: var(--text-m); white-space: nowrap; font-size: 12px; }

/* ══════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════ */
@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
  .modal-sheet { border-radius: var(--r-2xl); border: 1px solid var(--border); margin: 16px; max-height: 88vh; }
}
@media (min-width: 900px) {
  .app-main { padding: 32px 32px 100px; }
  .app-tabs { padding: 0 32px; }
  .app-header { padding: 0 32px; }
}

/* ── Tablet ── */
@media (max-width: 860px) {
  .login-brand { display: none; }
  .login-form-panel { width: 100%; max-width: 100%; padding: 48px 40px; justify-content: center; }
}

/* ── Mobile ── */
@media (max-width: 599px) {
  /* Login */
  .login-screen { align-items: flex-start; }
  .login-form-panel { padding: 40px 24px 32px; min-height: 100dvh; }
  .login-mobile-logo { display: flex; }
  .login-form-title  { font-size: 22px; }
  .login-form-header { margin-bottom: 24px; }
  .login-field input { font-size: 16px; } /* prevents iOS zoom */

  /* Header */
  .app-header { height: 56px; padding: 0 16px; }
  .brand-sub, .brand-divider { display: none; }
  .brand-name { font-size: 14px; }
  .logo-img   { height: 28px; }
  .btn-label  { display: none; }
  .btn        { padding: 7px 10px; }

  /* Tabs */
  .app-tabs { padding: 0 16px; }
  .tab-btn  { padding: 0 14px; font-size: 12.5px; }

  /* Main */
  .app-main { padding: 14px 12px 90px; }

  /* Stats */
  .stats-grid { grid-template-columns: repeat(2,1fr); gap: 10px; margin-bottom: 16px; }
  .stat-card  { padding: 12px; gap: 8px; flex-direction: column; align-items: flex-start; }
  .stat-icon  { width: 32px; height: 32px; border-radius: var(--r-sm); }
  .stat-n     { font-size: 24px; }
  .stat-l     { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

  /* Category bar */
  .cat-bar   { margin-bottom: 14px; }
  .cat-chip  { padding: 6px 12px; font-size: 12px; }

  /* Cat-filter row */
  .cat-filter-row { gap: 6px; }
  .filter-pills   { display: none; }
  /* Toolbar */
  .sort-select    { display: none; }
  .search-box     { flex: 1; }
  .search-box input { font-size: 16px; } /* no iOS zoom */

  /* Items */
  .items-grid { grid-template-columns: repeat(2,1fr); gap: 10px; }
  .item-thumb { height: 100px; }
  .item-body  { padding: 10px; gap: 7px; }
  .item-name  { font-size: 12px; min-height: 2.6em; }
  .item-qty   { font-size: 22px; }
  .item-qty small { font-size: 10px; }
  .item-meta  { font-size: 10px; }
  .move-row button { font-size: 11.5px; padding: 7px 4px; }

  /* Reports */
  .report-grid-2 { grid-template-columns: 1fr; }
  .report-card   { padding: 16px; }
  .chart-wrap    { height: 220px; }
  .chart-wrap-tall { height: 340px; }

  /* FAB */
  .fab       { border-radius: 50%; width: 54px; height: 54px; padding: 0; justify-content: center; right: 16px; bottom: 16px; }
  .fab-label { display: none; }

  /* User pill */
  .user-pill span { display: none; }

  /* Modals — full width on mobile */
  .modal-sheet { max-height: 95dvh; }
  .modal-body  { padding: 16px 18px; }
  .modal-footer { padding: 0 18px 20px; }
  .modal-header { padding: 18px 18px 14px; }

  /* Table */
  .td-name { max-width: 110px; }
  .td-who  { display: none; }
}

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

/* ══════════════════════════════════════════════
   UTILITY
══════════════════════════════════════════════ */
.sr-only { position: absolute; width: 1px; height: 1px; clip: rect(0,0,0,0); overflow: hidden; }
.hidden  { display: none !important; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0D1B2A; --surface: #152232; --border: #1E3148; --border-l: #1A2D42;
    --text: #E0EFF9; --text-m: #6B9AB5; --text-l: #3D6882;
    --primary-xl: #0D2137;
  }
}
