/* ============================================================
   DESIGN TOKENS
   Exposed as CSS custom properties so the Appearance settings
   (My Profile > Custom Colors) can override --color-primary,
   --color-accent, --color-text at runtime via inline styles on
   :root, without touching this file.
   ============================================================ */
:root {
  /* Base palette - warm charcoal + saffron, tuned for a catering/food-service HR tool */
  --color-primary: #1F3A3D;      /* deep teal-charcoal - sidebar, headers */
  --color-primary-dark: #142627;
  --color-accent: #C97A2B;       /* saffron/turmeric - action color, distinct from generic terracotta */
  --color-accent-dark: #A8621E;
  --color-text: #1B1F1E;
  --color-text-muted: #616B69;
  --color-bg: #F7F5F1;           /* warm paper, not stark white */
  --color-surface: #FFFFFF;
  --color-border: #E4E0D8;

  --color-success: #2E7D4F;
  --color-success-bg: #E7F4EC;
  --color-warning: #B8860B;
  --color-warning-bg: #FBF2DD;
  --color-danger: #B3402A;
  --color-danger-bg: #FBEAE5;
  --color-info: #2A6F97;
  --color-info-bg: #E7F1F7;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 25, 24, 0.06);
  --shadow-md: 0 4px 16px rgba(20, 25, 24, 0.10);
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; }
button { font-family: inherit; }
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- App shell ---------- */
#app-root { height: 100%; display: none; }
#app-root.visible { display: flex; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--color-primary);
  color: #EDEFEE;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand .logo-mark {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  background: var(--color-accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; color: #1B1300;
}
.sidebar-brand .brand-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.sidebar-brand .brand-sub { font-size: 11px; color: rgba(237,239,238,0.6); }

.nav-section { padding: 14px 10px 4px; }
.nav-section-label {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(237,239,238,0.42);
  padding: 8px 10px 6px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: rgba(237,239,238,0.82);
  text-decoration: none;
  font-size: 13.5px;
  cursor: pointer;
  margin-bottom: 1px;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: var(--color-accent); color: #1B1300; font-weight: 600; }
.nav-item .nav-icon { width: 16px; text-align: center; opacity: 0.9; flex-shrink: 0; }

/* ---------- Main column ---------- */
.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100vh; }

.topbar {
  height: 60px;
  flex-shrink: 0;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.topbar-crumb { font-size: 13px; color: var(--color-text-muted); }
.topbar-crumb strong { color: var(--color-text); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.bell-btn {
  position: relative; background: none; border: none; cursor: pointer;
  font-size: 17px; color: var(--color-text-muted); padding: 6px;
}
.bell-btn .dot {
  position: absolute; top: 4px; right: 4px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--color-danger); border: 1.5px solid var(--color-surface);
}
.user-chip { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--color-primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 600; font-family: var(--font-display);
}
.user-chip-meta { line-height: 1.25; }
.user-chip-name { font-size: 13px; font-weight: 600; }
.user-chip-role { font-size: 11px; color: var(--color-text-muted); text-transform: capitalize; }

#page-content { flex: 1; overflow-y: auto; padding: 24px 28px 60px; }

/* ---------- Login screen ---------- */
#login-root { min-height: 100vh; display: none; }
#login-root.visible { display: flex; }
.login-panel-left {
  flex: 1.1;
  background: linear-gradient(160deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: #EDEFEE;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  position: relative;
  overflow: hidden;
}
.login-panel-left::after {
  content: "";
  position: absolute;
  right: -120px; bottom: -120px;
  width: 360px; height: 360px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--color-accent) 0%, transparent 70%);
  opacity: 0.35;
}
.login-headline {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 600;
  max-width: 420px;
  line-height: 1.2;
  position: relative;
  z-index: 1;
}
.login-sub { color: rgba(237,239,238,0.7); margin-top: 12px; max-width: 380px; position: relative; z-index: 1; }
.login-panel-right {
  flex: 1;
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}
.login-form-wrap { width: 100%; max-width: 340px; }
.login-form-wrap h2 { font-family: var(--font-display); font-size: 22px; margin: 0 0 4px; }
.login-form-wrap .lead { color: var(--color-text-muted); margin: 0 0 24px; font-size: 13.5px; }

/* ---------- Form elements ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: var(--color-text); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--color-accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(201, 122, 43, 0.14);
}
.field .hint { font-size: 11.5px; color: var(--color-text-muted); margin-top: 4px; }
.field .error-text { font-size: 11.5px; color: var(--color-danger); margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity 0.12s ease, background 0.12s ease;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--color-accent); color: #1B1300; }
.btn-primary:hover:not(:disabled) { background: var(--color-accent-dark); }
.btn-block { width: 100%; }
.btn-outline { background: transparent; border-color: var(--color-border); color: var(--color-text); }
.btn-outline:hover:not(:disabled) { border-color: var(--color-accent); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-ghost { background: transparent; border: none; color: var(--color-text-muted); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---------- Cards / tables / pills - shared shell used by every module ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.stat-card { display: flex; flex-direction: column; gap: 6px; }
.stat-card .stat-label { font-size: 11.5px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .stat-value { font-family: var(--font-display); font-size: 24px; font-weight: 600; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border); margin-bottom: 18px; flex-wrap: wrap; }
.tab-btn {
  background: none; border: none; padding: 9px 14px; font-size: 13px; font-weight: 600;
  color: var(--color-text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-btn.active { color: var(--color-text); border-bottom-color: var(--color-accent); }

.status-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.status-tab {
  padding: 7px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--color-surface); border: 1px solid var(--color-border); cursor: pointer; color: var(--color-text-muted);
}
.status-tab.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th {
  text-align: left; padding: 10px 12px; background: var(--color-bg);
  color: var(--color-text-muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em;
  border-bottom: 1px solid var(--color-border);
}
table.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
table.data-table tbody tr:hover { background: rgba(201, 122, 43, 0.04); cursor: default; }

.pill { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.pill-success { background: var(--color-success-bg); color: var(--color-success); }
.pill-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.pill-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.pill-info { background: var(--color-info-bg); color: var(--color-info); }
.pill-neutral { background: var(--color-bg); color: var(--color-text-muted); }

.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--color-text-muted); }
.empty-state .empty-icon { font-size: 28px; margin-bottom: 8px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,25,24,0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto; z-index: 100;
}
.modal {
  background: var(--color-surface); border-radius: var(--radius-lg);
  width: 100%; max-width: 620px; box-shadow: var(--shadow-md);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--color-border);
}
.modal-header h3 { margin: 0; font-family: var(--font-display); font-size: 17px; }
.modal-body { padding: 20px 22px; max-height: 65vh; overflow-y: auto; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: 10px; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.page-header h1 { font-family: var(--font-display); font-size: 22px; margin: 0; }
.page-header .page-sub { color: var(--color-text-muted); font-size: 13px; margin-top: 2px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .modal-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 90; transform: translateX(-100%); transition: transform 0.2s ease; }
  .sidebar.open { transform: translateX(0); }
  .login-panel-left { display: none; }
  #mobile-menu-btn { display: inline-flex !important; }
  #page-content { padding: 16px; }
  .topbar { padding: 0 14px; height: 54px; }
  .topbar-right { gap: 8px; }
  .user-chip-meta { display: none; }
  .bell-btn { padding: 4px; }
  .modal-backdrop { padding: 0; align-items: stretch; }
  .modal { max-width: 100%; border-radius: 0; min-height: 100vh; }
  .stat-value { font-size: 19px; }
  .page-header h1 { font-size: 18px; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions .btn { flex: 1 1 auto; }
}

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.15); border-top-color: var(--color-accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast-stack { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--color-primary); color: #fff; padding: 11px 16px; border-radius: var(--radius-sm);
  font-size: 13px; box-shadow: var(--shadow-md); max-width: 320px;
}
.toast.toast-error { background: var(--color-danger); }
.toast.toast-success { background: var(--color-success); }
