/* NossoPosto — Design System v2 · Light Clean Professional */
/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== TOKENS ===== */
:root {
  --bg:             #f8fafc;
  --surface:        #ffffff;
  --surface2:       #f1f5f9;
  --surface3:       #e8edf3;
  --border:         #e2e8f0;
  --border2:        #cbd5e1;
  --text:           #0f172a;
  --text2:          #1e293b;
  --muted:          #64748b;
  --muted2:         #94a3b8;
  --brand:          #1e3a5f;
  --accent:         #2563eb;
  --accent-dark:    #1d4ed8;
  --accent-bg:      #eff6ff;
  --accent-border:  #bfdbfe;
  --green:          #15803d;
  --green2:         #16a34a;
  --green-bg:       #f0fdf4;
  --green-border:   #bbf7d0;
  --red:            #dc2626;
  --red-bg:         #fef2f2;
  --red-border:     #fecaca;
  --gold:           #92400e;
  --gold2:          #d97706;
  --gold-bg:        #fffbeb;
  --gold-border:    #fde68a;
  --sans:  'DM Sans', system-ui, sans-serif;
  --mono:  'JetBrains Mono', 'Courier New', monospace;
  --r-xs:  4px;
  --r:     6px;
  --r-md:  8px;
  --r-lg:  12px;
  --r-xl:  16px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.04);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.04);
  --h-topbar:  56px;
  --w-sidebar: 268px;
}

/* ===== BASE ===== */
html { scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
button { font-family: var(--sans); cursor: pointer; }

/* ===== TOPBAR ===== */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--h-topbar);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-xs);
}
.tb-logo { display: flex; align-items: center; flex-shrink: 0; }
.tb-logo img { height: 26px; width: auto; max-width: 160px; object-fit: contain; }
.tb-sep { flex: 1; }
.tb-divider { width: 1px; height: 20px; background: var(--border); flex-shrink: 0; }

/* Breadcrumb / subtitle */
.tb-crumb {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px; flex-shrink: 0; color: var(--muted);
}
.tb-crumb a { transition: color 0.12s; }
.tb-crumb a:hover { color: var(--accent); }
.tb-crumb .sep { color: var(--muted2); font-size: 10px; }
.tb-crumb .curr { color: var(--text2); font-weight: 500; }

/* Hamburger */
.hamburger {
  display: none; flex-direction: column; gap: 4px;
  padding: 7px 6px; background: none; border: 1px solid transparent;
  color: var(--muted); flex-shrink: 0; border-radius: var(--r);
  transition: all 0.12s;
}
.hamburger:hover { background: var(--surface2); border-color: var(--border); color: var(--text); }
.hamburger span { display: block; width: 16px; height: 1.5px; background: currentColor; border-radius: 1px; }
@media (max-width: 900px) { .hamburger { display: flex; } }

/* User nav dropdown */
.tb-user { position: relative; }
.tb-user-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 10px 5px 6px; border: 1px solid var(--border);
  border-radius: var(--r-md); background: transparent; cursor: pointer;
  font-size: 13px; color: var(--text2); font-weight: 500;
  transition: all 0.15s; user-select: none; font-family: var(--sans);
}
.tb-user-btn:hover, .tb-user.open .tb-user-btn {
  background: var(--surface2); border-color: var(--border2);
}
.tb-avatar {
  width: 24px; height: 24px; background: var(--accent);
  border-radius: var(--r-xs); display: flex; align-items: center;
  justify-content: center; font-size: 10px; font-weight: 700;
  color: white; flex-shrink: 0; text-transform: uppercase;
}
.tb-uname { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-role {
  font-size: 9px; font-family: var(--mono); letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--muted); background: var(--surface2);
  border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px;
}
.tb-role.master { background: var(--accent-bg); border-color: var(--accent-border); color: var(--accent); }
.tb-chevron { font-size: 9px; color: var(--muted2); transition: transform 0.15s; }
.tb-user.open .tb-chevron { transform: rotate(180deg); }
.tb-dropdown {
  display: none; position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-md);
  min-width: 210px; z-index: 200; overflow: hidden;
}
.tb-user.open .tb-dropdown { display: block; }
.tb-dd-section { padding: 4px 0; border-bottom: 1px solid var(--border); }
.tb-dd-section:last-child { border-bottom: none; }
.tb-dd-label {
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted2);
  padding: 8px 14px 3px;
}
.tb-dd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; font-size: 13px; color: var(--text2);
  text-decoration: none; transition: background 0.1s;
}
.tb-dd-item:hover { background: var(--surface2); }
.tb-dd-item.danger { color: var(--red); }
.tb-dd-item.danger:hover { background: var(--red-bg); }
.tb-dd-icon { font-size: 13px; width: 16px; text-align: center; flex-shrink: 0; }

/* ===== ADMIN SUB-NAV (tabs) ===== */
.admin-nav {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 24px; display: flex; gap: 0; overflow-x: auto;
}
.admin-nav::-webkit-scrollbar { display: none; }
.admin-nav a {
  display: flex; align-items: center; gap: 6px;
  padding: 11px 16px; font-size: 13px; font-weight: 500;
  color: var(--muted); border-bottom: 2px solid transparent;
  transition: all 0.12s; white-space: nowrap; text-decoration: none;
}
.admin-nav a:hover { color: var(--text2); }
.admin-nav a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ===== LAYOUT ===== */
.app-layout {
  display: grid;
  grid-template-columns: var(--w-sidebar) 1fr;
  min-height: calc(100vh - var(--h-topbar));
}

/* ===== SIDEBAR ===== */
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 16px 12px; display: flex; flex-direction: column;
  gap: 14px; position: sticky; top: var(--h-topbar);
  height: calc(100vh - var(--h-topbar)); overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--border2) transparent;
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.sidebar-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(15,23,42,0.45); z-index: 90; backdrop-filter: blur(2px);
}
@media (max-width: 900px) {
  .sidebar-backdrop.visible { display: block; }
  .sidebar {
    position: fixed !important; top: var(--h-topbar) !important;
    left: 0 !important; width: var(--w-sidebar) !important;
    height: calc(100vh - var(--h-topbar)) !important;
    transform: translateX(-110%);
    transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
    z-index: 95; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .app-layout { grid-template-columns: 1fr; }
}

/* ===== MAIN / PAGE WRAP ===== */
.main-content { padding: 24px 28px; overflow-x: auto; }
.page-wrap { max-width: 1200px; margin: 0 auto; padding: 28px 24px; }
@media (max-width: 900px) {
  .main-content { padding: 16px; }
  .page-wrap { padding: 20px 16px; }
}

/* ===== SECTION LABEL ===== */
.section-label {
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted2);
  margin-bottom: 6px;
}

/* ===== PAGE HEADER ===== */
.page-hd {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; line-height: 1.2; }
.page-desc { font-size: 13px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ===== STATS ROW ===== */
.stats-row { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 14px 18px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow-xs); flex: 1; min-width: 120px;
}
.stat-icon {
  font-size: 18px; width: 40px; height: 40px; border-radius: var(--r);
  background: var(--surface2); display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
}
.stat-val { font-family: var(--mono); font-size: 22px; font-weight: 700; line-height: 1; color: var(--text); }
.stat-label { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--r); font-family: var(--sans);
  font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.15s;
  border: 1px solid transparent; white-space: nowrap;
  text-decoration: none; line-height: 1.3;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn-primary {
  background: var(--accent); color: white; border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(37,99,235,0.2);
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); box-shadow: 0 4px 10px rgba(37,99,235,0.3); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
  background: var(--surface); color: var(--text2);
  border-color: var(--border2); box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--surface2); }
.btn-danger { background: var(--surface); color: var(--red); border-color: var(--red-border); }
.btn-danger:hover { background: var(--red-bg); }
.btn-ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn-ghost:hover { background: var(--surface2); color: var(--text2); }
.btn-sm { padding: 4px 10px; font-size: 12px; gap: 4px; border-radius: var(--r-xs); }
.btn-lg { padding: 10px 20px; font-size: 14px; }
.btn-full { width: 100%; justify-content: center; }

/* ===== CARD ===== */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow-xs);
}
.card + .card { margin-top: 16px; }
.card-hd {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card-hd h2 { font-size: 14px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.card-hd h3 {
  font-size: 10px; font-weight: 600; color: var(--muted);
  letter-spacing: 0.08em; text-transform: uppercase; font-family: var(--mono);
}
.card-hd-end { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 18px; }
.card-icon { font-size: 16px; }

/* ===== FORM ===== */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
  font-size: 11px; font-weight: 600; color: var(--muted);
  letter-spacing: 0.05em; text-transform: uppercase;
}
.field input, .field select, .field textarea {
  padding: 8px 12px; border: 1.5px solid var(--border);
  border-radius: var(--r); font-family: var(--sans); font-size: 13px;
  color: var(--text); background: var(--surface); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s; line-height: 1.4;
}
.field input:hover, .field select:hover { border-color: var(--border2); }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.field select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 28px; cursor: pointer;
}

/* ===== BADGE ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px; font-size: 11px;
  font-weight: 500; line-height: 1.5; white-space: nowrap;
}
.badge-blue  { background: var(--accent-bg);  color: var(--accent);  border: 1px solid var(--accent-border); }
.badge-green { background: var(--green-bg);   color: var(--green2);  border: 1px solid var(--green-border); }
.badge-red   { background: var(--red-bg);     color: var(--red);     border: 1px solid var(--red-border); }
.badge-gold  { background: var(--gold-bg);    color: var(--gold);    border: 1px solid var(--gold-border); }
.badge-gray  { background: var(--surface2);   color: var(--muted);   border: 1px solid var(--border); }

/* ===== TABLE ===== */
.table-wrap {
  overflow-x: auto; scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}
.table-wrap::-webkit-scrollbar { height: 3px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

table.dtable { width: 100%; border-collapse: collapse; font-size: 13px; }
table.dtable thead tr { background: var(--surface2); border-bottom: 2px solid var(--border); }
table.dtable thead th {
  padding: 10px 16px; text-align: left; font-family: var(--mono);
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted); white-space: nowrap;
}
table.dtable thead th.num { text-align: right; }
table.dtable tbody tr { border-bottom: 1px solid var(--border); transition: background 0.08s; }
table.dtable tbody tr:hover { background: #f7f9fc; }
table.dtable tbody tr:last-child { border-bottom: none; }
table.dtable td { padding: 11px 16px; color: var(--text2); vertical-align: middle; }
table.dtable td.num { text-align: right; font-family: var(--mono); font-size: 12px; white-space: nowrap; }
table.dtable td.muted { color: var(--muted); font-size: 12px; }

/* ===== ALERT ===== */
.alert {
  padding: 10px 14px; border-radius: var(--r); font-size: 13px;
  display: flex; align-items: flex-start; gap: 8px; margin-bottom: 16px;
}
.alert-error   { background: var(--red-bg);    border: 1px solid var(--red-border);    color: var(--red); }
.alert-success { background: var(--green-bg);  border: 1px solid var(--green-border);  color: var(--green2); }
.alert-info    { background: var(--accent-bg); border: 1px solid var(--accent-border); color: var(--accent); }

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,0.5);
  backdrop-filter: blur(2px); display: none; align-items: center;
  justify-content: center; z-index: 300; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 440px; padding: 24px;
  animation: modal-in 0.18s ease;
}
@keyframes modal-in { from { opacity:0; transform: scale(0.97) translateY(4px); } to { opacity:1; transform: scale(1) translateY(0); } }
.modal h3 { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; letter-spacing: -0.01em; }
.modal-sub { font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.65);
  backdrop-filter: blur(4px); z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.loading-overlay.visible { opacity: 1; pointer-events: all; }
.loading-spinner {
  width: 36px; height: 36px; border: 2.5px solid rgba(255,255,255,0.15);
  border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-msg {
  font-family: var(--mono); font-size: 11px; color: rgba(255,255,255,0.55);
  letter-spacing: 0.1em; text-transform: uppercase;
}

/* ===== EMPTY STATE ===== */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 360px; gap: 12px; text-align: center; color: var(--muted);
}
.empty-icon { font-size: 42px; opacity: 0.3; }
.empty h2 { font-size: 18px; font-weight: 600; color: var(--muted); }
.empty p { font-size: 13px; max-width: 300px; line-height: 1.6; }

/* ===== TOAST ===== */
.toast {
  padding: 11px 16px; border-radius: var(--r-md); font-size: 13px;
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px;
  animation: slide-in 0.22s ease;
}
@keyframes slide-in { from { opacity:0; transform: translateY(-6px); } to { opacity:1; transform: translateY(0); } }
.toast-success { background: var(--green-bg);  border: 1px solid var(--green-border); color: var(--green2); }
.toast-error   { background: var(--red-bg);    border: 1px solid var(--red-border);   color: var(--red); }
.toast-info    { background: var(--accent-bg); border: 1px solid var(--accent-border); color: var(--accent); }

/* ===== PRINT ===== */
@media print {
  .topbar, .admin-nav, .sidebar, .hamburger, .loading-overlay,
  .sidebar-backdrop, .page-actions, .btn { display: none !important; }
  body { background: white; font-size: 11px; }
  .app-layout { grid-template-columns: 1fr; }
  .main-content { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; border: 1px solid #ccc; }
}
