@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
    --ink: #1F2430;
    --ink-soft: #3A4152;
    --paper: #F2F1ED;
    --paper-raised: #FFFFFF;
    --line: #DCD9D0;
    --plum: #7A2E3B;
    --plum-dark: #5E2230;
    --pass-green: #4C7A5E;
    --pass-green-soft: #E4EEE8;
    --amber: #B9812E;
    --amber-soft: #F6ECD9;
    --danger: #A6403A;
    --danger-soft: #F5E4E2;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(31,36,48,.06), 0 4px 14px rgba(31,36,48,.05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

h1, h2, h3, .display {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.01em;
    margin: 0 0 .3em;
}

a { color: inherit; }
:focus-visible { outline: 2px solid var(--plum); outline-offset: 2px; }

.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; }

/* ---------- Layout shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--ink);
    color: #E7E5DE;
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sidebar .brand {
    font-family: 'Fraunces', serif;
    font-weight: 700;
    font-size: 20px;
    color: #fff;
    padding: 4px 10px 22px;
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.sidebar .brand small {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--amber);
    font-weight: 500;
    letter-spacing: .04em;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar a.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #C6C3BA;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background .12s ease, color .12s ease;
}
.sidebar a.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar a.nav-link.active { background: var(--plum); color: #fff; }
.sidebar .nav-ico { width: 18px; text-align: center; opacity: .85; }
.sidebar .spacer { flex: 1; }
.sidebar .user-box {
    border-top: 1px solid rgba(255,255,255,.12);
    padding-top: 14px;
    margin-top: 8px;
    font-size: 13px;
}
.sidebar .user-box .u-name { color: #fff; font-weight: 600; }
.sidebar .user-box .u-role { color: var(--amber); text-transform: uppercase; font-size: 10.5px; letter-spacing: .06em; font-family: 'IBM Plex Mono', monospace; }
.sidebar .logout-link { color: #C6C3BA; font-size: 12.5px; text-decoration: none; display: inline-block; margin-top: 8px; }
.sidebar .logout-link:hover { color: #fff; }

.main { flex: 1; min-width: 0; padding: 28px 34px 60px; }

.topbar { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 10px; }
.topbar .eyebrow { font-family: 'IBM Plex Mono', monospace; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--plum); font-weight: 600; margin-bottom: 4px; display: block; }

/* ---------- Cards / panels ---------- */
.panel {
    background: var(--paper-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat-card {
    background: var(--paper-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}
.stat-card .stat-label { font-family: 'IBM Plex Mono', monospace; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.stat-card .stat-value { font-family: 'Fraunces', serif; font-size: 30px; font-weight: 600; margin-top: 4px; }
.stat-card.accent-plum .stat-value { color: var(--plum); }
.stat-card.accent-green .stat-value { color: var(--pass-green); }
.stat-card.accent-amber .stat-value { color: var(--amber); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--ink); color: #fff;
    border: none; border-radius: 8px;
    padding: 9px 16px; font-size: 13.5px; font-weight: 600;
    cursor: pointer; text-decoration: none; font-family: 'Inter', sans-serif;
    transition: transform .08s ease, opacity .12s ease;
}
.btn:hover { opacity: .88; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--plum); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 6px; }

/* ---------- Forms ---------- */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
    width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px;
    background: var(--paper-raised); font-family: 'Inter', sans-serif; font-size: 14px; color: var(--ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--plum); }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Tables ---------- */
table.data { width: 100%; border-collapse: collapse; }
table.data th {
    text-align: left; font-family: 'IBM Plex Mono', monospace; font-size: 11px;
    text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft);
    padding: 10px 12px; border-bottom: 1px solid var(--line);
}
table.data td { padding: 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #FAF9F6; }

.badge {
    display: inline-block; padding: 3px 9px; border-radius: 100px;
    font-size: 11px; font-weight: 600; font-family: 'IBM Plex Mono', monospace; text-transform: uppercase; letter-spacing: .03em;
}
.badge-available, .badge-paid { background: var(--pass-green-soft); color: var(--pass-green); }
.badge-occupied, .badge-in_kitchen { background: var(--amber-soft); color: var(--amber); }
.badge-reserved, .badge-new { background: #E9E6DD; color: var(--ink-soft); }
.badge-ready { background: var(--pass-green-soft); color: var(--pass-green); }
.badge-served { background: #E4E7F5; color: #3A4E9E; }
.badge-cancelled { background: var(--danger-soft); color: var(--danger); }

/* ---------- Login page ---------- */
.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: var(--ink); padding: 20px;
    background-image: radial-gradient(circle at 20% 20%, rgba(122,46,59,.35), transparent 45%),
                       radial-gradient(circle at 85% 80%, rgba(76,122,94,.25), transparent 45%);
}
.login-card { width: 100%; max-width: 380px; background: var(--paper-raised); border-radius: 14px; padding: 34px 30px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card .brand { font-family: 'Fraunces', serif; font-size: 26px; font-weight: 700; margin-bottom: 2px; }
.login-card .tag { font-family: 'IBM Plex Mono', monospace; font-size: 11.5px; color: var(--plum); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 22px; display: block; }
.login-hint { font-size: 12.5px; color: var(--ink-soft); margin-top: 16px; background: var(--paper); border: 1px dashed var(--line); padding: 10px 12px; border-radius: 8px; }

/* ---------- Flash ---------- */
.flash { padding: 11px 14px; border-radius: 8px; font-size: 13.5px; font-weight: 500; margin-bottom: 18px; }
.flash-success { background: var(--pass-green-soft); color: var(--pass-green); }
.flash-error { background: var(--danger-soft); color: var(--danger); }

/* ---------- Kitchen ticket rail (signature element) ---------- */
.ticket-rail { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }

.ticket {
    background: var(--paper-raised);
    position: relative;
    padding: 16px 16px 14px;
    border-radius: 3px;
    box-shadow: var(--shadow);
    border-top: 3px dashed var(--line);
}
.ticket::before {
    content: "";
    position: absolute; top: -1px; left: 0; right: 0; height: 8px;
    background-image: radial-gradient(circle 5px at 12px 0, transparent 5px, var(--paper) 5.5px),
                       radial-gradient(circle 5px at 36px 0, transparent 5px, var(--paper) 5.5px),
                       radial-gradient(circle 5px at 60px 0, transparent 5px, var(--paper) 5.5px),
                       radial-gradient(circle 5px at 84px 0, transparent 5px, var(--paper) 5.5px),
                       radial-gradient(circle 5px at 108px 0, transparent 5px, var(--paper) 5.5px),
                       radial-gradient(circle 5px at 132px 0, transparent 5px, var(--paper) 5.5px),
                       radial-gradient(circle 5px at 156px 0, transparent 5px, var(--paper) 5.5px),
                       radial-gradient(circle 5px at 180px 0, transparent 5px, var(--paper) 5.5px);
    background-repeat: repeat-x;
}
.ticket .t-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.ticket .t-code { font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: 15px; color: var(--ink); }
.ticket .t-meta { font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }
.ticket .t-items { list-style: none; margin: 10px 0; padding: 0; border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line); padding: 10px 0; }
.ticket .t-items li { display: flex; justify-content: space-between; font-size: 13px; padding: 2px 0; }
.ticket .t-items li .qty { font-family: 'IBM Plex Mono', monospace; color: var(--plum); font-weight: 600; margin-right: 6px; }
.ticket .t-total { display: flex; justify-content: space-between; font-weight: 700; font-family: 'IBM Plex Mono', monospace; font-size: 14px; margin-top: 8px; }
.ticket .t-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }

.badge-inquiry { background: #E9E6DD; color: var(--ink-soft); }
.badge-quoted { background: var(--amber-soft); color: var(--amber); }
.badge-confirmed { background: var(--pass-green-soft); color: var(--pass-green); }
.badge-in_progress { background: #E4E7F5; color: #3A4E9E; }
.badge-completed { background: #E4E7F5; color: #3A4E9E; }
.badge-draft { background: #E9E6DD; color: var(--ink-soft); }
.badge-sent { background: var(--amber-soft); color: var(--amber); }
.badge-received { background: var(--pass-green-soft); color: var(--pass-green); }
.badge-unpaid { background: var(--danger-soft); color: var(--danger); }
.badge-deposit_paid { background: var(--amber-soft); color: var(--amber); }
.badge-paid_in_full { background: var(--pass-green-soft); color: var(--pass-green); }
.badge-tentative { background: #E9E6DD; color: var(--ink-soft); }
.badge-booked { background: var(--amber-soft); color: var(--amber); }

/* ---------- Event planner ---------- */
.task-row, .vendor-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.task-row:last-child, .vendor-row:last-child { border-bottom: none; }
.task-row form { margin: 0; }
.task-check {
    width: 22px; height: 22px; flex-shrink: 0; margin-top: 1px;
    border: 1px solid var(--line); border-radius: 6px; background: var(--paper-raised);
    color: var(--pass-green); font-size: 13px; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.task-row.task-done .task-check { background: var(--pass-green-soft); border-color: var(--pass-green); }
.task-row.task-done .task-title { text-decoration: line-through; color: var(--ink-soft); }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 14px; }
.task-meta { font-size: 12.5px; color: var(--ink-soft); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.tag {
    display: inline-block; background: #EAE8E1; color: var(--ink-soft);
    border-radius: 100px; padding: 1px 8px; font-size: 11px; font-weight: 600;
}
.timeline { position: relative; }
.timeline-row { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; }
.timeline-time { width: 66px; flex-shrink: 0; font-size: 12.5px; color: var(--ink-soft); padding-top: 2px; }
.timeline-line { width: 8px; height: 8px; border-radius: 50%; background: var(--plum); margin-top: 6px; flex-shrink: 0; }
.timeline-body { flex: 1; min-width: 0; }
.timeline-row form { margin: 0; }

/* ---------- Catering: event dossier cards ---------- */
.event-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.event-card {
    background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 18px 20px; text-decoration: none; color: var(--ink); display: block;
}
.event-card:hover { border-color: var(--plum); }
.event-card .e-date {
    font-family: 'IBM Plex Mono', monospace; font-size: 11px; text-transform: uppercase;
    letter-spacing: .05em; color: var(--plum); font-weight: 600; margin-bottom: 6px;
}
.event-card h3 { font-size: 17px; margin-bottom: 2px; }
.event-card .e-meta { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 12px; }
.event-card .e-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.event-card .e-guests { font-family: 'IBM Plex Mono', monospace; font-size: 12.5px; color: var(--ink-soft); }

/* ---------- Catering: phase groups (food schedule) ---------- */
.phase-group { margin-bottom: 18px; }
.phase-group .phase-label {
    font-family: 'IBM Plex Mono', monospace; font-size: 11px; text-transform: uppercase;
    letter-spacing: .06em; color: var(--plum); font-weight: 600; margin-bottom: 8px;
    display: flex; align-items: center; gap: 8px;
}
.phase-group .phase-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Catering: estimate summary ---------- */
.estimate-box { background: var(--paper); border: 1px dashed var(--line); border-radius: 8px; padding: 14px 16px; }
.estimate-line { display: flex; justify-content: space-between; font-size: 13.5px; padding: 4px 0; }
.estimate-line.total { font-weight: 700; font-size: 16px; font-family: 'Fraunces', serif; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
.estimate-line.deposit { color: var(--ink-soft); }

@media print {
    .sidebar, .topbar a, .btn, .page-actions, .flash, form button, .no-print { display: none !important; }
    .main { padding: 0; }
    body { background: #fff; }
    .panel { box-shadow: none; border: none; }
}

.empty-state { text-align: center; padding: 50px 20px; color: var(--ink-soft); }
.empty-state .display { font-size: 20px; margin-bottom: 6px; }

.page-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.filter-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-tabs a { padding: 6px 13px; border-radius: 100px; font-size: 12.5px; font-weight: 600; text-decoration: none; color: var(--ink-soft); background: #EAE8E1; }
.filter-tabs a.active { background: var(--ink); color: #fff; }

.modal-overlay { position: fixed; inset: 0; background: rgba(31,36,48,.55); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--paper-raised); border-radius: 12px; padding: 24px; width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto; }

@media (max-width: 780px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; flex-direction: row; align-items: center; overflow-x: auto; padding: 12px; }
    .sidebar nav { flex-direction: row; }
    .sidebar .user-box, .sidebar .spacer { display: none; }
    .main { padding: 18px; }
    .field-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
