/* ============================================================
   KAFECO-INT Inventory System v3.0 — Main Stylesheet
   Zero external dependencies — works fully offline/XAMPP
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:     #1a6644;
  --green-mid: #22854f;
  --green-lt:  #d1f0e0;
  --green-pale:#f0faf4;
  --blue:      #1d4ed8;
  --blue-lt:   #dbeafe;
  --indigo:    #4338ca;
  --indigo-lt: #e0e7ff;
  --amber:     #d97706;
  --amber-lt:  #fef3c7;
  --red:       #dc2626;
  --red-lt:    #fee2e2;
  --stone-900: #1c1917;
  --stone-800: #292524;
  --stone-700: #44403c;
  --stone-600: #57534e;
  --stone-500: #78716c;
  --stone-400: #a8a29e;
  --stone-300: #d6d3d1;
  --stone-200: #e7e5e4;
  --stone-100: #f5f5f4;
  --stone-50:  #fafaf9;
  --white:     #ffffff;
  --nav-h:     64px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'Courier New', Courier, monospace;
}

html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--stone-50);
  color: var(--stone-900);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Navbar ──────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 200;
  height: var(--nav-h);
  background: var(--white);
  border-bottom: 1px solid var(--stone-200);
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.nav-inner {
  max-width: 1280px; margin: 0 auto;
  padding: 0 1.5rem; width: 100%;
  height: 100%; display: flex; align-items: center;
  justify-content: space-between; gap: 1rem;
}
.nav-brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; }

.nav-logo {
  width: 40px; height: 40px; background: var(--green);
  border-radius: 10px; display: flex; align-items: center;
  justify-content: center; font-size: 1.35rem; color: var(--white);
  font-weight: 900; flex-shrink: 0;
}

.nav-logo-img {
  height: 45px; /* Marginally smaller to leave clean padding in a 64px navbar */
  max-width: 150px; /* Safe upper cap for mobile layouts */
  width: auto;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

/* On desktops and larger tablets, give the wide logo more breathing room */
@media (min-width: 768px) {
  .nav-logo-img {
    height: 48px;
    max-width: 220px;
  }
}

/*
.nav-logo {
  width: 40px; height: 40px; background: var(--green);
  border-radius: 10px; display: flex; align-items: center;
  justify-content: center; font-size: 1.35rem; color: var(--white);
  font-weight: 900; flex-shrink: 0;
}
*/
.nav-brand-text strong { display: block; font-size: .95rem; font-weight: 700; color: var(--stone-900); }
.nav-brand-text small  { display: block; font-size: .62rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--stone-400); }
.nav-right { display: flex; align-items: center; gap: .75rem; }
.nav-user { text-align: right; display: none; }
@media (min-width:640px) { .nav-user { display: block; } }
.nav-user strong { display: block; font-size: .85rem; font-weight: 600; color: var(--stone-900); }
.nav-user small  { font-size: .72rem; color: var(--stone-500); }

/* Role badges */
.role-badge {
  display: inline-block; padding: .15rem .55rem; border-radius: 99px;
  font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
.role-admin      { background: #ede9fe; color: #5b21b6; }
.role-director { background: var(--blue-lt); color: var(--blue); }
.role-supervisor { background: var(--green-lt); color: var(--green); }

.btn-icon {
  width: 36px; height: 36px; background: var(--stone-100);
  border: none; border-radius: 9px; display: flex; align-items: center;
  justify-content: center; color: var(--stone-600); cursor: pointer;
  text-decoration: none; transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--stone-200); color: var(--stone-900); }

/* ── Main ────────────────────────────────── */
.main-wrap { flex: 1; max-width: 1280px; margin: 0 auto; width: 100%; padding: 2rem 1.5rem; }

/* ── Page header ─────────────────────────── */
.page-header {
  background: var(--white); border-radius: 20px;
  padding: 1.75rem 2rem; border: 1px solid var(--stone-200);
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 1.5rem; margin-bottom: 1.75rem;
}
.page-header-left { display: flex; align-items: center; gap: 1rem; }
.page-icon { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.page-icon svg { width: 26px; height: 26px; }
.page-header-left h2 { font-size: 1.5rem; font-weight: 800; color: var(--stone-900); line-height: 1.1; }
.page-header-left p  { font-size: .83rem; color: var(--stone-500); margin-top: .25rem; }

/* ── Tabs ────────────────────────────────── */
.tab-bar { display: flex; background: var(--stone-100); border-radius: 12px; padding: 4px; gap: 2px; }
.tab-btn {
  padding: .5rem 1.2rem; border: none; border-radius: 9px;
  background: transparent; font-family: var(--font-sans); font-size: .82rem;
  font-weight: 600; color: var(--stone-500); cursor: pointer;
  transition: all .18s; white-space: nowrap;
}
.tab-btn.active { background: var(--white); color: var(--green); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

/* ── Card ────────────────────────────────── */
.card { background: var(--white); border-radius: 20px; border: 1px solid var(--stone-200); overflow: hidden; }
.card-pad { padding: 1.5rem; }
.card-title { font-weight: 700; font-size: .95rem; color: var(--stone-900); display: flex; align-items: center; gap: .5rem; }
.card-title svg { color: var(--green); }

/* ── Grid helpers ────────────────────────── */
.grid-2  { display: grid; grid-template-columns: repeat(2,1fr); gap: 1rem; }
.grid-3  { display: grid; grid-template-columns: repeat(3,1fr); gap: 1.25rem; }
.grid-13 { display: grid; grid-template-columns: 1fr 2fr; gap: 1.75rem; }

@media (max-width:900px) {
  .grid-13 { grid-template-columns: 1fr; }
  .grid-3  { grid-template-columns: repeat(2,1fr); }
}
@media (max-width:540px) {
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .main-wrap { padding: 1rem; }
  .page-header { padding: 1.25rem; }
}

/* ── Stat card ───────────────────────────── */
.stat-card { background: var(--white); border: 1px solid var(--stone-200); border-radius: 20px; padding: 1.5rem; }
.stat-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.stat-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.stat-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--stone-400); }
.stat-value { font-size: 2.1rem; font-weight: 800; color: var(--stone-900); line-height: 1; }
.stat-sub   { font-size: .75rem; color: var(--stone-500); margin-top: .35rem; }

/* ── Forms ───────────────────────────────── */
.field { margin-bottom: 1rem; }
label, .field-label {
  display: block; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--stone-500); margin-bottom: .45rem;
}
input[type=text], input[type=email], input[type=number],
input[type=password], input[type=date], select, textarea {
  width: 100%; padding: .7rem 1rem;
  background: var(--stone-50); border: 1.5px solid var(--stone-200);
  border-radius: 11px; font-family: var(--font-sans); font-size: .875rem;
  color: var(--stone-900); outline: none;
  transition: border-color .18s, box-shadow .18s; appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--green); box-shadow: 0 0 0 3px rgba(26,102,68,.1);
}
textarea { resize: vertical; min-height: 80px; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2378716c' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2.5rem;
}

/* ── Buttons ─────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .7rem 1.4rem; border: none; border-radius: 11px;
  font-family: var(--font-sans); font-size: .875rem; font-weight: 700;
  cursor: pointer; transition: all .18s; text-decoration: none;
}
.btn-green  { background: var(--green);  color: #fff; box-shadow: 0 3px 10px rgba(26,102,68,.25); }
.btn-green:hover { background: #154f34; }
.btn-blue   { background: var(--blue);   color: #fff; }
.btn-blue:hover  { background: #1e40af; }
.btn-ghost  { background: var(--stone-100); color: var(--stone-700); }
.btn-ghost:hover { background: var(--stone-200); }
.btn-danger { background: var(--red-lt); color: var(--red); }
.btn-danger:hover { background: #fca5a5; }
.btn-amber  { background: var(--amber-lt); color: var(--amber); }
.btn-sm     { padding: .42rem .95rem; font-size: .78rem; }
.btn-full   { width: 100%; }
.btn:disabled { opacity: .55; pointer-events: none; }

/* ── Tables ──────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--stone-50); }
thead th {
  padding: .875rem 1.25rem; font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--stone-500);
  white-space: nowrap; text-align: left;
}
tbody tr { border-top: 1px solid var(--stone-100); transition: background .1s; }
tbody tr:hover { background: var(--stone-50); }
tbody td { padding: .875rem 1.25rem; font-size: .875rem; color: var(--stone-800); }
.tbl-empty td { padding: 3rem 1.25rem; text-align: center; color: var(--stone-400); font-style: italic; }

/* ── Badges ──────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; padding: .2rem .65rem;
  border-radius: 99px; font-size: .65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
.badge-green  { background: var(--green-lt);  color: var(--green); }
.badge-amber  { background: var(--amber-lt);  color: var(--amber); }
.badge-blue   { background: var(--blue-lt);   color: var(--blue); }
.badge-purple { background: #ede9fe; color: #6d28d9; }
.badge-red    { background: var(--red-lt);    color: var(--red); }

/* ── Type toggle ─────────────────────────── */
.type-toggle { display: grid; grid-template-columns:1fr 1fr; background: var(--stone-100); border-radius:11px; padding:4px; margin-bottom:1rem; }
.type-btn { padding:.55rem; border:none; border-radius:8px; font-family:var(--font-sans); font-size:.8rem; font-weight:700; cursor:pointer; background:transparent; color:var(--stone-500); display:flex; align-items:center; justify-content:center; gap:.35rem; transition:all .18s; }
.type-btn.active-in  { background:var(--white); color:var(--green); box-shadow:0 1px 4px rgba(0,0,0,.08); }
.type-btn.active-out { background:var(--white); color:var(--amber); box-shadow:0 1px 4px rgba(0,0,0,.08); }

/* ── Alert / info boxes ──────────────────── */
.alert { display:flex; align-items:flex-start; gap:.65rem; border-radius:12px; padding:.9rem 1rem; font-size:.84rem; margin-bottom:1.25rem; }
.alert-error { background:#fef2f2; border:1px solid #fecaca; color:var(--red); }
.alert-info  { background:var(--blue-lt); border:1px solid #bfdbfe; color:var(--blue); }

/* ── Toast ───────────────────────────────── */
#toast {
  position:fixed; bottom:1.5rem; right:1.5rem; z-index:9999;
  background:var(--stone-900); color:#fff; padding:.85rem 1.25rem;
  border-radius:12px; font-size:.875rem; font-weight:500;
  display:none; box-shadow:0 8px 24px rgba(0,0,0,.25);
  max-width:320px; animation:toastIn .3s ease;
}
#toast.show      { display:flex; align-items:center; gap:.5rem; }
#toast.toast-ok  { background:var(--green); }
#toast.toast-err { background:var(--red); }
@keyframes toastIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

/* ── Utility ─────────────────────────────── */
.text-bold { font-weight:700; }
.text-sm   { font-size:.8rem; }
.text-muted{ color:var(--stone-500); }
.text-mono { font-family:var(--font-mono); font-weight:700; }
.text-red  { color:var(--red); }
.text-green{ color:var(--green); }
.mt-1{margin-top:.5rem}.mt-2{margin-top:1rem}.mt-3{margin-top:1.5rem}
.mb-1{margin-bottom:.5rem}.mb-2{margin-bottom:1rem}
.flex{display:flex}.gap-1{gap:.5rem}.items-center{align-items:center}
.justify-between{justify-content:space-between}.flex-wrap{flex-wrap:wrap}
.section-gap{margin-bottom:1.75rem}
.sticky-top{position:sticky;top:calc(var(--nav-h) + 1.5rem);align-self:start}
.divider{border:none;border-top:1px solid var(--stone-100);margin:1.25rem 0}

/* ── Spinner ─────────────────────────────── */
.spin{width:18px;height:18px;border:2.5px solid rgba(255,255,255,.3);border-top-color:#fff;border-radius:50%;animation:spin .7s linear infinite;display:inline-block;vertical-align:middle}
@keyframes spin{to{transform:rotate(360deg)}}

/* ── Low stock indicator ─────────────────── */
.low-stock { color: var(--red); font-weight: 700; }
.low-stock-row { background: #fff5f5 !important; }

/* ── Progress bar ────────────────────────── */
.progress-bar-wrap { background: var(--stone-100); border-radius: 99px; height: 6px; overflow: hidden; margin-top: .5rem; }
.progress-bar      { height: 100%; border-radius: 99px; background: var(--green); transition: width .4s; }

/* ── Site footer ─────────────────────────── */
.site-footer { background: var(--white); border-top: 1px solid var(--stone-200); padding: 1.25rem 1.5rem; text-align: center; font-size: .8rem; color: var(--stone-500); margin-top: auto; }

/* ── Print ───────────────────────────────── */
@media print {
  .nav, .btn-print-hide, #toast { display: none !important; }
  .main-wrap { padding: 0; }
  .card { border: none; box-shadow: none; }
}