:root {
    --bg: #f4f6f8;
    --card: #fff;
    --ink: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --brand: #1d4ed8;
    --brand-ink: #fff;
    --danger: #b91c1c;
    --radius: 12px;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f172a; --card: #1e293b; --ink: #f1f5f9; --muted: #94a3b8; --line: #334155;
        --brand: #3b82f6; --danger: #f87171;
    }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--ink);
    font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 .5rem; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.pad { padding: 1rem; }

.topbar {
    display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem;
    padding-top: max(.6rem, env(safe-area-inset-top));
    background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; text-decoration: none; color: var(--ink); }
.topbar nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.topbar nav a { padding: .4rem .7rem; border-radius: 8px; text-decoration: none; color: var(--ink); }
.topbar nav a.active, .topbar nav a:hover { background: var(--bg); }

.container { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.container-wide { max-width: none; padding: 1rem; }
.flash { background: #dcfce7; color: #166534; padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.error { color: var(--danger); font-size: .85rem; }
.error-box { background: #fee2e2; color: #991b1b; padding: .7rem 1rem; border-radius: 8px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.card.flush { padding: 0; overflow: hidden; }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.form-narrow { max-width: 720px; }
fieldset { border: 0; margin: 0 0 1rem; }
legend { font-weight: 600; padding: 0; margin-bottom: .6rem; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
@media (max-width: 600px) { .row-2 { grid-template-columns: 1fr; } }

label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; }
input, select, textarea {
    font: inherit; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px;
    background: var(--card); color: var(--ink); width: 100%; min-height: 44px;
}
input[type=checkbox] { width: auto; min-height: 0; }
input[type=file] { padding: .45rem; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    font: inherit; font-weight: 600; padding: .6rem 1rem; min-height: 44px;
    border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink);
    text-decoration: none; cursor: pointer;
}
.btn:hover { filter: brightness(.97); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-lg { font-size: 1.15rem; padding: .9rem 1.6rem; min-height: 56px; }
.btn-sm { min-height: 34px; padding: .25rem .7rem; font-size: .85rem; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.danger-zone { margin-top: 2rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }

.login-card { max-width: 380px; margin: 12vh auto 0; }

/* Dashboard */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
@media (max-width: 700px) { .tiles { grid-template-columns: 1fr; } }
.tile {
    display: flex; flex-direction: column; gap: .2rem; padding: 1.4rem; text-decoration: none; color: var(--ink);
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); min-height: 150px;
    transition: transform .08s;
}
.tile:active { transform: scale(.98); }
.tile strong { font-size: 1.3rem; }
.tile small { color: var(--muted); }
.tile-icon { font-size: 2rem; line-height: 1; margin-bottom: auto; color: var(--brand); }
.tile-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.tile-primary small, .tile-primary .tile-icon { color: rgba(255,255,255,.85); }
.dash-grid { display: grid; grid-template-columns: 1fr 320px; gap: 1rem; align-items: start; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-bottom: .6rem; }
.legend i { display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; margin-right: .3rem; }
.fc { --fc-border-color: var(--line); --fc-page-bg-color: var(--card); --fc-neutral-bg-color: var(--bg); --fc-today-bg-color: rgba(59,130,246,.1); }
.fc .fc-button { min-height: 38px; }

.list-row {
    display: flex; flex-direction: column; gap: .1rem; padding: .8rem 1rem; text-decoration: none; color: var(--ink);
    border-bottom: 1px solid var(--line);
}
a.list-row:hover { background: var(--bg); }
.list-row:last-child { border-bottom: 0; }
.list-row span { color: var(--muted); font-size: .9rem; }
.card:not(.flush) > .list-row { padding-left: 0; padding-right: 0; }
.flush .list-row { flex-direction: row; align-items: center; gap: .8rem; }
.flush .list-row > strong { flex: 1; }
.filters { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filters input { flex: 1; min-width: 180px; }
.filters select { width: auto; }

.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; background: #e5e7eb; color: #374151; }
.badge-quote_pending { background: #fef3c7; color: #92400e; }
.badge-in_progress { background: #dbeafe; color: #1e40af; }
.badge-completed { background: #dcfce7; color: #166534; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }

.prompt { max-width: 640px; margin: 8vh auto 0; text-align: center; padding: 2rem 1.5rem; }
.prompt h1 { margin: .5rem 0; }
.prompt .actions { justify-content: center; margin-top: 1.5rem; }

.details { display: grid; grid-template-columns: 9rem 1fr; gap: .6rem 1rem; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }

/* Tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: .75rem; }
.tab {
    font: inherit; font-weight: 600; padding: .7rem 1.1rem; background: none; border: 0; border-bottom: 3px solid transparent;
    color: var(--muted); cursor: pointer; min-height: 44px;
}
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
[hidden] { display: none !important; }

/* Slideshow */
.show { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; height: calc(100dvh - 190px); min-height: 360px; }
.show:fullscreen { border-radius: 0; height: 100dvh; }
.show-stage, .slide { width: 100%; height: 100%; margin: 0; }
.slide { position: relative; display: flex; align-items: center; justify-content: center; }
.slide img { max-width: 100%; max-height: 100%; object-fit: contain; }
.slide iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.slide figcaption { position: absolute; left: 0; right: 0; bottom: 0; padding: .8rem 4rem; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.75)); pointer-events: none; }
.slide figcaption span { display: block; opacity: .85; font-size: .9rem; }
.nav { position: absolute; top: 50%; transform: translateY(-50%); width: 52px; height: 80px; border: 0; background: rgba(0,0,0,.4); color: #fff; font-size: 2.4rem; cursor: pointer; }
.nav-prev { left: 0; border-radius: 0 10px 10px 0; }
.nav-next { right: 0; border-radius: 10px 0 0 10px; }
.show-count { position: absolute; top: .6rem; right: .8rem; color: #fff; background: rgba(0,0,0,.5); padding: .1rem .6rem; border-radius: 999px; font-size: .85rem; }

@media print {
    .topbar, .tabs, .plan-toolbar, .page-head a { display: none !important; }
}
