/* =====================================================================
   Restaurant Manager — design system
   CSS variables + a small set of reusable components. No framework,
   no build step.
   ===================================================================== */

:root {
  --bg: #f6f4f0;
  --surface: #ffffff;
  --surface-alt: #f1ece3;
  --border: #e4ddd0;
  --text: #29241f;
  --text-muted: #756a5c;

  --primary: #ae4a1c;
  --primary-dark: #8c3a15;
  --primary-contrast: #fff8f3;

  --success: #15803d;
  --success-bg: #e8f5ec;
  --danger: #b91c1c;
  --danger-bg: #fbeaea;
  --warning: #a15c07;
  --warning-bg: #fbf0dc;
  --info: #1d4ed8;
  --info-bg: #e8eefc;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(41, 36, 31, 0.06), 0 2px 8px rgba(41, 36, 31, 0.06);
  --shadow-hover: 0 4px 16px rgba(41, 36, 31, 0.12);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;

  --header-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1815;
    --surface: #252019;
    --surface-alt: #2c2620;
    --border: #423a30;
    --text: #f1ece3;
    --text-muted: #a89a86;

    --primary: #e07b40;
    --primary-dark: #f0a071;
    --primary-contrast: #241000;

    --success: #4ade80;
    --success-bg: #163020;
    --danger: #f87171;
    --danger-bg: #341717;
    --warning: #eab84e;
    --warning-bg: #3a2c0e;
    --info: #93b4fb;
    --info-bg: #182339;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.4);
  }
}

/* =========================
   Reset & base
============================ */

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

html {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-serif);
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 0.5em;
}

h1 {
  font-size: 1.75rem;
}

h2 {
  font-size: 1.3rem;
}

h3 {
  font-size: 1.1rem;
}

p {
  line-height: 1.5;
}

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

a:hover {
  text-decoration: underline;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

ul.plain {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* =========================
   Layout
============================ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav {
  height: var(--header-h);
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.brand {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand:hover {
  text-decoration: none;
  color: var(--primary);
}

.brand-mark {
  display: inline-flex;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--primary-contrast);
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: auto;
}

.nav-links a {
  color: var(--text-muted);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 600;
}

.nav-links a:hover {
  color: var(--text);
  background: var(--surface-alt);
  text-decoration: none;
}

.nav-links a.active {
  color: var(--primary);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.nav-toggle {
  display: none;
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 40px;
  height: 40px;
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
}

main {
  flex: auto;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

.site-footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 1.5rem 1.25rem;
}

@media (max-width: 760px) {
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .nav-links,
  .nav-user {
    display: none;
    width: 100%;
  }

  .nav {
    flex-wrap: wrap;
    height: auto;
    padding: 0.75rem 1.25rem;
  }

  .site-header.open .nav-links,
  .site-header.open .nav-user {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
    padding-bottom: 0.75rem;
  }

  .site-header.open .nav-user {
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
    flex-direction: row;
    justify-content: space-between;
  }
}

/* =========================
   Page heading / breadcrumb
============================ */

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.page-head h1 {
  margin: 0;
}

.breadcrumb ul {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.breadcrumb li+li::before {
  content: "/";
  margin: 0 0.5em;
  color: var(--border);
}

.breadcrumb li.edit {
  margin-left: auto;
}

.breadcrumb li.edit::before {
  content: none;
}

/* =========================
   Buttons
============================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  padding: 0.55em 1.1em;
  font-size: 0.92rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  line-height: 1.2;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-contrast);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--surface-alt);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  filter: brightness(0.92);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.btn-sm {
  padding: 0.35em 0.75em;
  font-size: 0.82rem;
}

.btn-icon {
  padding: 0.4em;
  width: 2.1em;
  height: 2.1em;
}

.btn-block {
  width: 100%;
}

.actions-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1.25rem;
  flex-wrap: wrap;
}

.actions-row> :last-child:not(:first-child) {
  margin-left: auto;
}

/* =========================
   Cards
============================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.card+.card {
  margin-top: 1rem;
}

.card-title {
  margin: 0 0 0.75rem;
}

/* =========================
   Stat tiles
============================ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.9rem;
  margin: 0 0 1.75rem;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
}

.stat-tile .stat-value {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.1;
}

.stat-tile .stat-label {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 0.3rem;
}

.stat-tile.is-warning .stat-value {
  color: var(--warning);
}

/* =========================
   Tables
============================ */

.table-responsive {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.table-responsive table {
  border: none;
  box-shadow: none;
  margin: 0;
}

th,
td {
  padding: 0.7rem 0.9rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

thead th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--surface-alt);
}

.group-heading th,
.group-heading td {
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}

.group-heading h2 {
  margin: 0.15em 0;
  font-size: 1rem;
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

td.actions,
th.actions {
  text-align: right;
  white-space: nowrap;
}

/* =========================
   Badges
============================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.2em 0.65em;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-neutral {
  background: var(--surface-alt);
  color: var(--text-muted);
}

/* =========================
   Alerts / messages
============================ */

.messages {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.alert {
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  border: 1px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 30%, transparent);
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
}

.alert-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: color-mix(in srgb, var(--warning) 30%, transparent);
}

.alert-info,
.alert-debug {
  background: var(--info-bg);
  color: var(--info);
  border-color: color-mix(in srgb, var(--info) 30%, transparent);
}

.alert-close {
  margin-left: auto;
  background: none;
  border: none;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.alert-close:hover {
  opacity: 1;
}

/* =========================
   Forms
============================ */

.form {
  max-width: 480px;
}

.form p {
  margin: 0 0 1.1em;
  display: flex;
  flex-direction: column;
}

.form label {
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 0.4em;
}

.form input[type="text"],
.form input[type="password"],
.form input[type="number"],
.form input[type="email"],
.form input[type="datetime-local"],
.form select,
.form textarea {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.55em 0.7em;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

.form input:focus,
.form select:focus,
.form textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.form textarea {
  min-height: 8em;
  resize: vertical;
}

.form input[type="checkbox"] {
  width: 1.1em;
  height: 1.1em;
  accent-color: var(--primary);
  margin-right: 0.4em;
}

.form ul.errorlist {
  list-style: none;
  margin: 0.3em 0 0;
  padding: 0;
  color: var(--danger);
  font-size: 0.82rem;
}

.form .helptext {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.3em;
}

.form-wide {
  max-width: none;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin: 1em 0;
}

.checkbox-row label {
  margin: 0;
  font-weight: 500;
}

.field-inline {
  display: inline-flex;
  align-items: center;
}

.field-inline input {
  width: 6em;
  padding: 0.35em 0.5em;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

/* =========================
   Empty state
============================ */

.empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

/* =========================
   Home / dashboard
============================ */

.hero {
  text-align: center;
  padding: 1.5rem 0 2rem;
}

.hero h1 {
  font-size: 2rem;
}

.hero .lede {
  color: var(--text-muted);
  margin-top: -0.25rem;
}

.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  max-width: 720px;
  margin: 1.75rem auto 0;
}

.quick-link {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.25rem;
  text-align: center;
  color: var(--text);
  font-weight: 600;
  font-family: var(--font-serif);
  font-size: 1.05rem;
}

.quick-link .quick-link-icon {
  display: block;
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
}

.quick-link:hover {
  text-decoration: none;
  box-shadow: var(--shadow-hover);
  border-color: var(--primary);
  color: var(--primary);
}

/* =========================
   Auth pages
============================ */

.auth-page {
  max-width: 380px;
  margin: 2rem auto;
}

.auth-page .card {
  text-align: left;
}

.auth-page h1 {
  text-align: center;
  margin-bottom: 1.25rem;
}

.auth-switch {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* =========================
   Misc utility
============================ */

.text-muted {
  color: var(--text-muted);
}

.mt-0 {
  margin-top: 0;
}