/* ============================================================
   SUPREME FAMILY - V.1  |  App stylesheet (light + dark)
   ============================================================ */

:root {
  --primary: #2456d8;
  --primary-600: #1d46b8;
  --primary-050: #eef3fe;
  --accent: #f59e0b;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .16);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="light"] {
  --bg: #f1f4fa;
  --bg-soft: #e9edf5;
  --card: #ffffff;
  --card-soft: #f7f9fc;
  --text: #17203a;
  --text-2: #4b5672;
  --text-3: #8b94ab;
  --border: #dfe5f0;
  --border-strong: #c9d3e4;
  --input-bg: #ffffff;
  --hover: #eef2f9;
  --danger-soft: #fee2e2;
  --success-soft: #dcfce7;
  --warning-soft: #fef3c7;
  --info-soft: #dbeafe;
  --accent-soft: #fef3c7;
  --table-stripe: #f8fafd;
  --toast-bg: #1e293b;
  --toast-text: #f8fafc;
}

[data-theme="dark"] {
  --bg: #0e1420;
  --bg-soft: #131b2b;
  --card: #182234;
  --card-soft: #1e2a40;
  --text: #e8edf7;
  --text-2: #a8b3c9;
  --text-3: #6d7892;
  --border: #2a3750;
  --border-strong: #39486b;
  --input-bg: #131b2b;
  --hover: #22304a;
  --danger-soft: #3f1d22;
  --success-soft: #15301f;
  --warning-soft: #3b2c10;
  --info-soft: #16273f;
  --accent-soft: #3b2c10;
  --table-stripe: #15203a;
  --toast-bg: #33415c;
  --toast-text: #f1f5fb;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  transition: background .25s ease, color .25s ease;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.25; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
small { color: var(--text-3); }

svg.ic { width: 20px; height: 20px; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 10px;
  height: 60px; padding: 0 14px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff; font-weight: 800; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: .5px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 14px; letter-spacing: .3px; }
.brand-text small { font-size: 11px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px; line-height: 1;
}
.icon-btn:hover { background: var(--hover); }
.sidebar-toggle { display: none; flex-direction: column; gap: 4px; padding: 10px 9px; }
.sidebar-toggle span { width: 20px; height: 2px; background: var(--text-2); border-radius: 2px; }

.user-menu { position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: transparent; border: 0; cursor: pointer;
  color: var(--text); padding: 4px 6px; border-radius: 10px;
}
.user-chip:hover { background: var(--hover); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary-050); color: var(--primary);
  font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
}
.user-chip-txt { display: flex; flex-direction: column; text-align: left; line-height: 1.2; }
.user-chip-txt b { font-size: 13px; }
.user-chip-txt small { font-size: 11px; }
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 220px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); overflow: hidden; z-index: 70;
}
.user-dropdown .ud-head { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; }
.user-dropdown a { display: block; padding: 10px 14px; color: var(--text); font-size: 14px; }
.user-dropdown a:hover { background: var(--hover); text-decoration: none; }
.user-dropdown a.danger { color: var(--danger); }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; top: 60px; left: 0; bottom: 0; width: 250px;
  background: var(--card); border-right: 1px solid var(--border);
  overflow-y: auto; z-index: 50; display: flex; flex-direction: column;
  transition: transform .25s ease;
}
.side-nav { padding: 12px 10px 20px; flex: 1; }
.nav-group {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-3); padding: 16px 10px 6px; font-weight: 700;
}
.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; margin-bottom: 2px;
  border-radius: 10px; color: var(--text-2);
  font-size: 14px; font-weight: 500; text-decoration: none;
}
.side-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.side-link:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.side-link-primary {
  background: linear-gradient(135deg, var(--primary), #3b6df0);
  color: #fff; box-shadow: 0 4px 14px rgba(36, 86, 216, .35);
}
.side-link-primary:hover { color: #fff; background: linear-gradient(135deg, var(--primary-600), #2f5cd8); }
.side-link.nav-danger { color: var(--danger); }
.sidebar-foot { padding: 12px 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(10, 14, 26, .5);
  z-index: 45; backdrop-filter: blur(2px);
}

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 55;
  display: none; align-items: stretch;
  background: var(--card); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px; color: var(--text-3); font-size: 10.5px; font-weight: 600;
  text-decoration: none;
}
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a.on { color: var(--primary); }
.bottom-nav a.entry svg { width: 30px; height: 30px; margin-top: -8px; filter: drop-shadow(0 3px 6px rgba(36,86,216,.4)); }
.bottom-nav a.entry { color: var(--primary); }

/* ---------- Main layout ---------- */
.main {
  margin-left: 250px;
  padding: 20px 22px 60px;
  min-height: 100vh;
  max-width: 1500px;
}

/* ---------- Flash / toast ---------- */
.flash {
  padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px;
  font-weight: 600; font-size: 14px;
}
.flash-success { background: var(--success-soft); color: var(--success); border: 1px solid rgba(22,163,74,.25); }
.flash-error { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(220,38,38,.25); }

.toast-stack {
  position: fixed; top: 70px; right: 16px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
}
.toast {
  background: var(--toast-bg); color: var(--toast-text);
  padding: 12px 16px; border-radius: 12px; font-size: 14px;
  box-shadow: var(--shadow-lg); display: flex; align-items: flex-start; gap: 10px;
  animation: toast-in .3s ease; cursor: pointer;
}
.toast b { font-weight: 700; }
.toast.t-success { border-left: 4px solid var(--success); }
.toast.t-error { border-left: 4px solid var(--danger); }
.toast.t-info { border-left: 4px solid var(--primary); }
@keyframes toast-in { from { transform: translateY(-12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }

.stat-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 18px;
}
.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 4px;
  position: relative; overflow: hidden;
}
.stat-card .stat-label { font-size: 12px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.stat-card .stat-value { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-2); }
.stat-card.primary { background: linear-gradient(135deg, var(--primary), #5b7ff0); color: #fff; border: 0; }
.stat-card.primary .stat-label, .stat-card.primary .stat-sub { color: rgba(255,255,255,.85); }
.stat-card.accent { background: linear-gradient(135deg, #b45309, var(--accent)); color: #fff; border: 0; }
.stat-card.accent .stat-label, .stat-card.accent .stat-sub { color: rgba(255,255,255,.9); }
.stat-card.success { background: linear-gradient(135deg, #15803d, #22c55e); color: #fff; border: 0; }
.stat-card.success .stat-label, .stat-card.success .stat-sub { color: rgba(255,255,255,.9); }
.stat-card.danger { background: linear-gradient(135deg, #b91c1c, #ef4444); color: #fff; border: 0; }
.stat-card.danger .stat-label, .stat-card.danger .stat-sub { color: rgba(255,255,255,.9); }
.stat-card.dark { background: var(--card-soft); }

/* ---------- Warning alert ---------- */
.warn-card {
  background: var(--card); border: 1px solid rgba(220,38,38,.35);
  border-left: 5px solid var(--danger);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.warn-card .warn-title { color: var(--danger); font-weight: 800; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.warn-card .warn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 10px; }
.warn-card .warn-cell { background: var(--danger-soft); border-radius: 10px; padding: 8px 10px; }
.warn-card .warn-cell b { display: block; font-size: 15px; }
.warn-card .warn-cell small { font-size: 11px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
table.tbl th {
  text-align: left; padding: 11px 12px; background: var(--card-soft);
  color: var(--text-2); font-size: 12px; text-transform: uppercase;
  letter-spacing: .4px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tbody tr:nth-child(even) { background: var(--table-stripe); }
table.tbl tbody tr:hover { background: var(--hover); }
table.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .actions { white-space: nowrap; text-align: right; }
.tbl .actions .btn { padding: 6px 10px; font-size: 12.5px; }
.tbl tfoot tr.total-row td {
  background: var(--card-soft); border-top: 2px solid var(--border-strong);
  font-size: 14px; padding: 12px;
}

/* ---------- Employee Production Report ---------- */
.emp-rep-head { text-align: center; padding: 18px 12px 14px; border-bottom: 2px solid var(--border-strong); margin-bottom: 14px; }
.emp-rep-brand { font-size: 22px; font-weight: 800; letter-spacing: .5px; }
.emp-rep-addr { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.emp-rep-title { font-size: 17px; margin: 10px 0 8px; }
.emp-rep-meta { display: flex; flex-wrap: wrap; gap: 8px 26px; justify-content: center; font-size: 13.5px; }
.emp-rep-meta span { color: var(--text-2); }
.emp-rep-tbl td { overflow-wrap: anywhere; }
.emp-total-box {
  margin: 18px auto 6px; padding: 16px 12px; max-width: 420px; text-align: center;
  border-top: 2px solid var(--border-strong); border-bottom: 2px solid var(--border-strong);
}
.emp-total-label { font-size: 13px; font-weight: 700; letter-spacing: 2px; color: var(--text-2); }
.emp-total-amount { font-size: clamp(30px, 7vw, 40px); font-weight: 800; letter-spacing: -.5px; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 18px; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none; line-height: 1.2;
  transition: filter .15s ease, transform .05s ease;
  font-family: var(--font);
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(36,86,216,.3); }
.btn-primary:hover { background: var(--primary-600); text-decoration: none; }
.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { background: var(--hover); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-outline { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger-outline:hover { background: var(--danger-soft); text-decoration: none; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--accent); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 14px 24px; font-size: 16px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.form-group label .req { color: var(--danger); }
.form-group .hint { font-size: 12px; color: var(--text-3); }
input[type="text"], input[type="number"], input[type="date"], input[type="email"],
input[type="password"], input[type="search"], input[type="tel"], select, textarea {
  width: 100%; padding: 11px 13px;
  background: var(--input-bg); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 15px; font-family: var(--font);
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(36,86,216,.18);
}
input[type="number"] { font-variant-numeric: tabular-nums; }
.search-box { position: relative; }
.search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); }
.search-box input { padding-left: 34px; }

/* Searchable select (JS enhanced) */
.sel-wrap { position: relative; }
.sel-wrap select { appearance: none; -webkit-appearance: none; padding-right: 34px;
  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='%238b94ab' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.sel-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40;
  background: var(--card); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  overflow: hidden; display: none;
}
.sel-dropdown.open { display: block; }
.sel-dropdown .sel-search { padding: 8px; border-bottom: 1px solid var(--border); }
.sel-dropdown .sel-search input { padding: 8px 10px; font-size: 14px; }
.sel-dropdown .sel-options { max-height: 260px; overflow-y: auto; }
.sel-dropdown .sel-opt { padding: 10px 12px; cursor: pointer; display: flex; align-items: center; gap: 8px; font-size: 14px; }
.sel-dropdown .sel-opt:hover { background: var(--hover); }
.sel-dropdown .sel-opt.sel { background: var(--primary-050); color: var(--primary); font-weight: 600; }
.sel-dropdown .sel-opt .sub { margin-left: auto; font-size: 11.5px; color: var(--text-3); }
.sel-dropdown .sel-empty { padding: 14px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .3px;
  text-transform: uppercase; white-space: nowrap;
}
.badge-green { background: var(--success-soft); color: var(--success); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-amber { background: var(--warning-soft); color: var(--warning); }
.badge-blue { background: var(--info-soft); color: var(--primary); }
.badge-gray { background: var(--bg-soft); color: var(--text-2); }
.badge-purple { background: #ede9fe; color: #7c3aed; }

/* ---------- Modals ---------- */
.modal-backdrop:not([hidden]) {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(10, 14, 26, .55); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 520px;
  max-height: calc(100vh - 40px); overflow-y: auto;
  animation: modal-in .22s ease;
}
.modal.lg { max-width: 760px; }
@keyframes modal-in { from { transform: translateY(14px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--card); z-index: 2; border-radius: var(--radius) var(--radius) 0 0; }
.modal-head h3 { margin: 0; }
.modal-body { padding: 18px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; background: var(--card); border-radius: 0 0 var(--radius) var(--radius); position: sticky; bottom: 0; }

/* ---------- Confirmation / summary panel ---------- */
.summary-panel {
  background: var(--card-soft); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px; margin-bottom: 14px;
}
.summary-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; font-size: 14px; }
.summary-row + .summary-row { border-top: 1px dashed var(--border); }
.summary-row .k { color: var(--text-2); }
.summary-row .v { font-weight: 600; text-align: right; }
.summary-row.total { font-size: 17px; font-weight: 800; color: var(--success); }
.summary-row.total .v { color: var(--success); }
.summary-row.head .k { font-weight: 800; color: var(--primary); text-transform: uppercase; letter-spacing: .5px; font-size: 12px; }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.toolbar .form-group { flex: 1 1 150px; min-width: 140px; }
.toolbar .form-group.wide { flex: 2 1 220px; }
.filter-card { padding: 16px; }
.filter-card .btn { align-self: flex-end; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span.page {
  min-width: 36px; height: 36px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-strong); border-radius: 9px;
  color: var(--text); font-size: 13.5px; font-weight: 600; text-decoration: none;
}
.pagination a:hover { background: var(--hover); text-decoration: none; }
.pagination .cur { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .dots { border: 0; color: var(--text-3); }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center; padding: 48px 20px; color: var(--text-3);
  display: flex; flex-direction: column; gap: 6px; align-items: center;
}
.empty-state .empty-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--bg-soft); display: flex; align-items: center; justify-content: center;
  font-size: 28px; margin-bottom: 6px; color: var(--text-3);
}
.empty-state b { color: var(--text-2); font-size: 15px; }
.empty-state p { font-size: 13px; max-width: 320px; }

/* ---------- Loading ---------- */
.loading-overlay:not([hidden]) {
  position: fixed; inset: 0; z-index: 110;
  background: rgba(10,14,26,.45); backdrop-filter: blur(2px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  color: var(--text);
}
.loading-overlay p { color: #fff; font-weight: 600; }
.spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.3); border-top-color: #fff;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn .spinner { width: 16px; height: 16px; border-width: 2px; border-color: rgba(255,255,255,.4); border-top-color: #fff; }

/* ---------- Production entry ---------- */
.entry-grid { display: grid; gap: 14px; max-width: 640px; margin: 0 auto; }
.entry-field {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
}
.entry-field label { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.entry-field .quick-add { font-size: 11px; font-weight: 700; color: var(--primary); background: var(--primary-050); border: 0; border-radius: 8px; padding: 5px 9px; cursor: pointer; }
.entry-field select, .entry-field .sel-wrap select { padding: 13px 14px; font-size: 16px; font-weight: 600; border-radius: 10px; }
.qty-input { text-align: center; font-size: 30px !important; font-weight: 800 !important; padding: 14px !important; letter-spacing: .5px; }
.calc-panel { background: var(--card-soft); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 16px; }
.calc-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 15px; }
.calc-row + .calc-row { border-top: 1px dashed var(--border); }
.calc-row .k { color: var(--text-2); }
.calc-row .v { font-weight: 700; }
.calc-row.earning { font-size: 19px; font-weight: 800; color: var(--success); }
.calc-row.earning .v { color: var(--success); }
.entry-actions { display: flex; gap: 10px; }
.entry-actions .btn { flex: 1; padding: 15px; font-size: 16px; border-radius: 12px; }

/* ---------- Second product/job entry ---------- */
.second-entry { display: grid; gap: 14px; padding: 16px; border: 1px dashed var(--primary); border-radius: var(--radius); background: var(--primary-050); }
.second-head { font-size: 12px; font-weight: 800; color: var(--primary); text-transform: uppercase; letter-spacing: .5px; }

/* ---------- Teamwork: team member selection ---------- */
.team-block { margin-top: 4px; }
.team-head { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.team-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.team-chip { display: inline-flex; align-items: center; gap: 7px; background: var(--primary); border: 1px solid var(--primary-600); color: #fff; border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 700; }
.team-chip button { background: rgba(255,255,255,.18); border: 0; color: #fff; font-size: 15px; line-height: 1; cursor: pointer; padding: 2px 7px; border-radius: 999px; }
.team-chip button:hover { background: var(--danger); color: #fff; }

/* ---------- User rights editor ---------- */
.rights-mod { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 10px; }
.rights-mod-name { font-size: 12px; font-weight: 800; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.rights-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.perm-chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.perm-chip input { accent-color: var(--primary); }
.perm-chip.on { background: var(--primary-050); border-color: var(--primary); color: var(--primary); }
.perm-chip.override { box-shadow: 0 0 0 1.5px var(--primary) inset; }

/* ---------- Login / auth pages ---------- */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: linear-gradient(160deg, #0f1f4d 0%, #1d3a8f 45%, #4f46e5 100%);
}
.auth-card {
  background: var(--card); border-radius: 20px; padding: 34px 30px;
  width: 100%; max-width: 420px; box-shadow: 0 24px 70px rgba(0,0,0,.35);
}
.auth-card .brand-mark { width: 56px; height: 56px; font-size: 20px; border-radius: 14px; margin-bottom: 14px; }
.auth-card h1 { font-size: 1.3rem; margin-bottom: 4px; }
.auth-card .sub { color: var(--text-3); font-size: 13.5px; margin-bottom: 22px; }
.auth-field { margin-bottom: 14px; }
.auth-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.auth-links { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; font-size: 13.5px; }
.auth-note { margin-top: 18px; padding: 12px; border-radius: 10px; background: var(--info-soft); color: var(--primary); font-size: 13px; text-align: center; }

/* ---------- Help center ---------- */
.help-lang { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.help-lang button { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--card); color: var(--text-2); font-weight: 600; cursor: pointer; font-size: 13.5px; }
.help-lang button.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.help-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.help-item {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; cursor: pointer; transition: border-color .15s ease, box-shadow .15s ease;
}
.help-item:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.help-item h4 { font-size: 14.5px; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.help-item .help-icon { width: 32px; height: 32px; border-radius: 9px; background: var(--primary-050); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }
.help-item p { font-size: 13px; color: var(--text-2); }

/* ---------- Misc ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-soft); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.divider { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.muted { color: var(--text-3); }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.flex { display: flex; } .flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.gap-1 { gap: 6px; } .gap-2 { gap: 10px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--success); } .text-danger { color: var(--danger); } .text-accent { color: var(--warning); }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.grow { flex: 1; }

/* charts */
.chart-box { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 18px; }
.chart-box h3 { margin-bottom: 10px; }
.chart-box canvas { max-height: 300px; }
.chart-canvas { position: relative; height: 260px; }

/* top 10 products */
.top10-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 18px; }
.top10-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.top10-card h3 { margin: 0 0 10px; font-size: 14px; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.top10-card h3 .muted { font-size: 11px; font-weight: 500; }
.top10-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.top10-row:last-child { border-bottom: 0; }
.top10-rank { width: 20px; height: 20px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.top10-rank:nth-child(1) { background: var(--primary); }
.top10-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top10-code { font-size: 11px; color: var(--text-3); }
.top10-qty { font-weight: 700; white-space: nowrap; }
.top10-qty small { font-weight: 500; color: var(--text-3); }
.top10-empty { padding: 14px 0; text-align: center; color: var(--text-3); font-size: 13px; }

/* segmented tabs */
.seg-tabs { display: flex; gap: 6px; background: var(--bg-soft); padding: 5px; border-radius: 12px; width: fit-content; max-width: 100%; overflow-x: auto; margin-bottom: 16px; }
.seg-tabs button {
  border: 0; background: transparent; padding: 9px 18px; border-radius: 9px;
  font-weight: 700; font-size: 13.5px; color: var(--text-2); cursor: pointer;
  white-space: nowrap;
}
.seg-tabs button.on { background: var(--card); color: var(--primary); box-shadow: var(--shadow); }

/* tabs content */
.tab-panel { display: none; }
.tab-panel.on { display: block; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-105%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .sidebar-toggle { display: inline-flex; }
  .main { margin-left: 0; padding: 16px 14px 90px; }
  .bottom-nav { display: flex; }
}

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .user-chip-txt { display: none; }
  .auth-card { padding: 26px 20px; }
  h1 { font-size: 1.25rem; }
  .entry-field { padding: 10px 12px; }
  .toast-stack { left: 16px; right: 16px; max-width: none; }
}

/* ---------- Mobile Production Entry (large touch controls) ---------- */
@media (max-width: 600px) {
  .entry-grid { gap: 10px; }
  .entry-field label { margin-bottom: 10px; }
  .entry-field select,
  .entry-field .sel-wrap select,
  .entry-field .sel-wrap .sel-trigger,
  .entry-field input[type="date"] {
    min-height: 52px; padding: 14px !important; font-size: 17px !important;
    border-radius: 12px !important;
  }
  .entry-field .sel-wrap .sel-trigger { align-items: center; }
  .entry-field .flex .btn { padding: 14px 16px; font-size: 15px; }
  .qty-input { font-size: 38px !important; min-height: 72px; }
  .calc-row { font-size: 16px; padding: 10px 0; }
  .calc-row .v { font-size: 17px; }
  .entry-actions { gap: 8px; }
  .entry-actions .btn { padding: 17px; font-size: 17px; border-radius: 14px; }
  .second-entry { padding: 14px; }
  .sel-wrap { position: static; }
  .sel-dropdown {
    position: fixed; left: 12px; right: 12px; bottom: 12px; top: auto;
    max-height: 60vh; border-radius: 16px; box-shadow: 0 -8px 30px rgba(15, 23, 42, .25);
    display: none; flex-direction: column;
  }
  .sel-dropdown.open { display: flex; }
  .sel-dropdown .sel-search { padding: 10px; }
  .sel-dropdown .sel-search input { padding: 13px 14px; font-size: 16px; border-radius: 10px; }
  .sel-dropdown .sel-options { max-height: none; flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .sel-dropdown .sel-opt { padding: 15px 14px; font-size: 16px; }
  .sel-dropdown .sel-opt .sub { font-size: 12.5px; }
}

@media print {
  .topbar, .sidebar, .bottom-nav, .toolbar, .btn, .pagination, .seg-tabs { display: none !important; }
  .main { margin: 0; padding: 0; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  /* Employee report: A4 print — only the report card, clean B/W table. */
  body.print-emp #empFilterCard,
  body.print-emp #empReportActions { display: none !important; }
  body.print-emp #empReportCard { display: block !important; border: none; }
  body.print-emp .emp-rep-head { border-bottom: 2px solid #000; }
  body.print-emp .emp-total-box { border-top-color: #000; border-bottom-color: #000; }
  body.print-emp .table-wrap { overflow: visible; border: none; }
  body.print-emp table.tbl { font-size: 10.5px; }
  body.print-emp table.tbl th, body.print-emp table.tbl td { padding: 6px 7px; }
  body.print-emp table.tbl thead { display: table-header-group; }
  body.print-emp table.tbl tr { page-break-inside: avoid; }
  body.print-emp table.tbl tfoot { display: table-footer-group; }
  body.print-emp .badge { border: 1px solid #666; }
  /* Employees Ledger: same A4 treatment, scoped to the ledger card. */
  body.print-ledger #ledgerFilterCard,
  body.print-ledger #ledgerActions { display: none !important; }
  body.print-ledger #ledgerCard { display: block !important; border: none; }
  body.print-ledger .emp-rep-head { border-bottom: 2px solid #000; }
  body.print-ledger .emp-total-box { border-top-color: #000; border-bottom-color: #000; }
  body.print-ledger .table-wrap { overflow: visible; border: none; }
  body.print-ledger table.tbl { font-size: 10.5px; }
  body.print-ledger table.tbl th, body.print-ledger table.tbl td { padding: 6px 7px; }
  body.print-ledger table.tbl thead { display: table-header-group; }
  body.print-ledger table.tbl tr { page-break-inside: avoid; }
  body.print-ledger table.tbl tfoot { display: table-footer-group; }
  body.print-ledger .badge { border: 1px solid #666; }
  @page { size: A4; margin: 12mm; }
}

/* ---------- Global: honor the hidden attribute (fixes overlay visibility) ---------- */
[hidden] { display: none !important; }

/* ---------- Quick Add (+) ---------- */
.qa-wrap { display: flex; align-items: center; gap: 8px; }
.qa-wrap select { flex: 1; min-width: 0; }
.qa-wrap input { flex: 1; min-width: 0; }
.quick-add-btn {
  flex: none; width: 42px; height: 42px; border-radius: 50%;
  border: 1.5px dashed var(--primary); background: var(--primary-soft, rgba(22, 101, 52, .08));
  color: var(--primary); font-size: 22px; font-weight: 700; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; touch-action: manipulation; user-select: none;
  transition: transform .12s ease, background .12s ease;
}
.quick-add-btn:active { transform: scale(.92); }
.quick-add-btn:hover { background: rgba(22, 101, 52, .16); }
.quick-add-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (max-width: 600px) {
  .quick-add-btn { width: 46px; height: 46px; }
}
#qaBackdrop[hidden] { display: none !important; }

/* ---------- Module Settings toggles ---------- */
.mod-list { display: flex; flex-direction: column; gap: 12px; }
.mod-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  border: 1px solid var(--border, #e2e8f0); border-radius: 12px; padding: 12px 14px;
}
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; border-radius: 26px; cursor: pointer;
  background: #cbd5e1; transition: background .18s ease;
}
.slider::before {
  content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, .3);
  transition: transform .18s ease;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ---------- Standalone Production Entry (factory-floor window) ---------- */
.standalone-body { background: var(--bg); min-height: 100vh; }
.standalone-wrap { max-width: 720px; margin: 0 auto; padding: 14px 16px 48px; }
.standalone-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.standalone-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.open-entry-btn { white-space: nowrap; }
@media (max-width: 600px) {
  .standalone-head { flex-direction: column; align-items: flex-start; }
  .standalone-actions { margin-left: 0; width: 100%; }
  .standalone-actions .btn { flex: 1; justify-content: center; }
  .open-entry-btn { padding: 8px 10px; font-size: 12px; }
}
@media (max-width: 420px) {
  .open-entry-btn { font-size: 0; }
  .open-entry-btn::before { content: '+'; font-size: 15px; margin-right: 0; }
}
.switch input:focus-visible + .slider { outline: 2px solid var(--primary); outline-offset: 2px; }
