:root {
    --ink: #14213d;
    --muted: #667085;
    --paper: #f6f7fb;
    --surface: #ffffff;
    --line: #e4e7ec;
    --teal: #087f8c;
    --teal-dark: #05616c;
    --gold: #e7a93b;
    --rose: #e05d5d;
    --shadow: 0 18px 45px rgba(20, 33, 61, .08);
    --shadow-soft: 0 8px 24px rgba(20, 33, 61, .06);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(8,127,140,0.10), transparent 23rem),
        radial-gradient(circle at bottom right, rgba(231,169,59,0.12), transparent 20rem),
        linear-gradient(135deg, #f5f7fb 0%, #edf3f5 100%);
    color: var(--ink);
    font-family: "Segoe UI", Candara, sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.shell { min-height: 100vh; }
.topbar { background: linear-gradient(110deg, #14213d 0%, #1d3652 60%, #087f8c 150%); color: white; box-shadow: 0 5px 20px rgba(20,33,61,.18); }
.topbar-inner, .page { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.topbar-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 28px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.02em; }
.brand-logo { width: 22px; height: 22px; display: block; flex-shrink: 0; border-radius: 7px; box-shadow: 0 4px 10px rgba(15, 23, 42, 0.18); }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: var(--gold); color: var(--ink); font-weight: 900; box-shadow: 0 4px 10px rgba(231,169,59,.2); }
.auth-card .brand { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.auth-card .brand-logo { width: 26px; height: 26px; }
.nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nav a { padding: 10px 12px; border-radius: 8px; color: #d8deeb; font-size: .92rem; }
.nav a:hover, .nav a.active { background: rgba(255,255,255,.12); color: white; }
.user-chip { color: #b9c4d8; font-size: .85rem; }
.user-menu { position: relative; color: #d8deeb; }
.user-menu summary { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px; cursor: pointer; list-style: none; font-size: .88rem; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: rgba(255,255,255,.12); color: white; }
.avatar { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 50%; background: var(--gold); color: var(--ink); font-size: .78rem; font-weight: 900; }
.menu-chevron { color: #b9c4d8; font-size: 1rem; }
.user-menu-panel { position: absolute; top: calc(100% + 8px); right: 0; z-index: 10; width: 205px; padding: 7px; border: 1px solid rgba(255,255,255,.12); border-radius: 10px; background: #1a2c48; box-shadow: 0 15px 30px rgba(0,0,0,.2); }
.user-menu-panel a { display: block; padding: 10px 11px; border-radius: 7px; color: #e0e6ef; font-size: .86rem; }
.user-menu-panel a:hover { background: rgba(255,255,255,.12); color: white; }

.page { padding: 48px 0 72px; }
.page-header { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.eyebrow { color: var(--teal); text-transform: uppercase; letter-spacing: .12em; font-size: .74rem; font-weight: 800; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 3.05rem; line-height: 1; letter-spacing: -.05em; margin-bottom: 12px; }
h2 { letter-spacing: -.03em; margin-bottom: 10px; }
.subtitle { color: var(--muted); max-width: 650px; line-height: 1.6; }

.card {
    background: rgba(255,255,255,.96);
    border: 1px solid rgba(228,231,236,.9);
    border-radius: 18px;
    box-shadow: var(--shadow-soft);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 34px rgba(20,33,61,.10);
    border-color: rgba(8,127,140,.18);
}
.card-pad { padding: 28px; }
.grid { display: grid; gap: 18px; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat { padding: 24px; }

.card a, a.card {
    display: block;
}
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { display: block; font-size: 2rem; font-weight: 800; margin-top: 8px; }

.btn {
    border: 0;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 17px;
    font-weight: 750;
    letter-spacing: .01em;
    transition: transform .15s, background .15s, box-shadow .15s, filter .15s;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.01); }
.btn-primary { background: linear-gradient(135deg, var(--teal) 0%, #1098a4 100%); color: white; box-shadow: 0 8px 16px rgba(8,127,140,.22); }
.btn-primary:hover { background: linear-gradient(135deg, var(--teal-dark) 0%, #0a7b87 100%); box-shadow: 0 10px 18px rgba(8,127,140,.27); }
.btn-secondary { background: #edf4f6; color: var(--ink); border: 1px solid rgba(20,33,61,.06); }
.btn-danger { background: #fff0ef; color: #b33c3c; }
.btn-small { padding: 9px 12px; font-size: .87rem; }

.form-card { max-width: 600px; }
.info-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 420px); gap: 20px; align-items: start; }
.info-content { min-height: 260px; line-height: 1.7; }
.formatted-content p:last-child { margin-bottom: 0; }
form p { margin-bottom: 16px; }
label { display: block; color: var(--muted); font-size: .85rem; font-weight: 700; margin-bottom: 7px; }
input, select, textarea { width: 100%; border: 1px solid #d0d5dd; border-radius: 8px; padding: 12px 13px; background: white; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(8,127,140,.15); border-color: var(--teal); }
.errorlist { color: #b33c3c; list-style: none; padding: 0; margin: 5px 0 0; font-size: .86rem; }
.messages { list-style: none; padding: 0; margin: 0 0 20px; }
.message { padding: 13px 16px; border-radius: 8px; background: #e7f6f3; color: #12635d; }

.calendar-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.calendar-card { overflow: hidden; }
.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 23px 26px; border-bottom: 1px solid var(--line); background: #fbfcfd; }
.calendar-toolbar h2 { margin: 0; font-size: 1.35rem; }
.calendar-mode { display: flex; justify-content: flex-end; padding: 12px 22px; border-bottom: 1px solid var(--line); background: #fbfcfd; }
.calendar-mode label { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--ink); cursor: pointer; }
.calendar-mode input { width: 17px; height: 17px; margin: 0; accent-color: var(--teal); }
.month-nav { display: flex; gap: 8px; }
.icon-btn { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--ink); font-size: 1.2rem; }
.weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekdays.weekdays-only, .calendar-grid.weekdays-only { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.weekdays { background: #f4f7f8; border-bottom: 1px solid var(--line); }
.weekdays span { padding: 12px 8px; color: var(--muted); text-align: center; font-size: .75rem; font-weight: 800; text-transform: uppercase; }
.day { min-height: 116px; padding: 10px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: white; transition: background .15s; }
.day:hover { background: #fcfefe; }
.day:nth-child(7n) { border-right: 0; }
.calendar-grid.weekdays-only .day:nth-child(5n) { border-right: 0; }
.day.muted { background: #fafbfc; color: #aab2bf; }
.day-number { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-size: .83rem; }
.day.today .day-number { background: var(--gold); font-weight: 800; box-shadow: 0 3px 8px rgba(231,169,59,.25); }
.day-action { display: block; width: 100%; min-height: 62px; padding: 5px; border: 0; border-radius: 8px; background: transparent; text-align: left; }
.day-action.available:hover { background: #e7f6f3; box-shadow: inset 0 0 0 1px rgba(8,127,140,.15); }
.day-action:disabled { cursor: not-allowed; }
.day-status { display: block; margin-top: 7px; padding: 5px 7px; border-radius: 6px; font-size: .72rem; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-status.free { background: #e7f6f3; color: #12635d; }
.day-status.booked { background: #fff0ef; color: #b33c3c; }
.day-status.mine { background: #fff4dc; color: #8a5a08; }
.day-status.absence { background: #fff0dc; color: #9b5d15; }
.day-status.locked { background: #f1f3f5; color: #8a94a3; }
.day-note { display: block; margin: 5px 4px 0; color: #9b5d15; font-size: .66rem; font-weight: 700; line-height: 1.2; }
.day-note.booked-by { margin-top: 4px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-delete-form { margin-top: 5px; }
.calendar-delete { border: 0; padding: 0; background: transparent; color: #b33c3c; font-size: .66rem; font-weight: 800; text-decoration: underline; }
.calendar-delete:hover { color: #8f2929; }
.calendar-legend { display: flex; gap: 18px; flex-wrap: wrap; padding: 16px 22px; color: var(--muted); font-size: .82rem; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.calendar-tools { margin-top: 24px; border-top: 1px solid var(--line); }
.calendar-tools details { padding: 18px 0; border-bottom: 1px solid var(--line); }
.calendar-tools summary { cursor: pointer; font-weight: 800; color: var(--ink); }
.calendar-tools p { margin: 12px 0; font-size: .86rem; line-height: 1.45; }
.calendar-tools ul { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 7px; }
.calendar-tools ul li { margin: 0; }
.calendar-tools ul label { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; color: var(--ink); }
.calendar-tools ul input { width: auto; margin: 0; vertical-align: middle; }
.calendar-tools ul li { display: flex; align-items: center; min-height: 28px; }
.routine-weekdays { margin-bottom: 16px; }
.field-label { display: block; color: var(--muted); font-size: .85rem; font-weight: 700; margin-bottom: 7px; }
.weekday-options { display: grid; gap: 6px; }
.weekday-option { display: flex; align-items: center; gap: 9px; min-height: 30px; margin: 0; color: var(--ink); font-weight: 600; cursor: pointer; }
.weekday-option input[type="checkbox"] { flex: 0 0 auto; width: 17px; height: 17px; margin: 0; accent-color: var(--teal); }
.field-help { display: block; margin-top: 7px; color: var(--muted); font-size: .78rem; line-height: 1.4; }

.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 20px 0; }
.table-card { overflow: hidden; }
.table-actions { display: flex; justify-content: flex-end; padding: 18px 20px 0; }
.table-wrap { overflow-x: auto; padding: 12px 0 0; }
.booking-actions, .form-actions { display: flex; align-items: center; gap: 8px; }
table {
    width: 100%;
    border-collapse: collapse;
    min-width: 680px;
}
th, td { padding: 17px 22px; border-bottom: 1px solid var(--line); text-align: left; font-size: .9rem; }
th {
    background: linear-gradient(180deg, #fbfcfd 0%, #f6f8fa 100%);
    color: var(--muted);
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .08em;
}
tr:last-child td { border-bottom: 0; }
tr:hover td { background: rgba(8,127,140,.02); }
.role-badge { display: inline-block; padding: 5px 9px; border-radius: 6px; font-size: .76rem; font-weight: 800; }
.role-badge.admin { background: #e7f6f3; color: #12635d; }
.role-badge.user { background: #edf1f5; color: var(--ink); }
.plate-badge { display: inline-block; margin: 2px 4px 2px 0; padding: 5px 8px; border: 1px solid #c8ced8; border-radius: 5px; background: #f8fafc; color: var(--ink); font-family: Consolas, monospace; font-size: .78rem; font-weight: 800; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--rose); }
.status-dot.active { background: var(--teal); }
.month-picker { display: flex; align-items: center; justify-content: space-between; width: min(340px, 100%); margin-bottom: 20px; padding: 12px 16px; }
.payment-badge { display: inline-block; padding: 6px 9px; border-radius: 6px; font-size: .76rem; font-weight: 800; }
.payment-badge.paid { background: #e7f6f3; color: #12635d; }
.payment-badge.open { background: #fff0ef; color: #b33c3c; }

.auth-wrap { min-height: 70vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #14213d 0%, #087f8c 100%); border-radius: 16px; }
.auth-card { width: min(440px, 100%); background: white; border-radius: 16px; padding: 34px; box-shadow: 0 25px 60px rgba(0,0,0,.18); }
.auth-card .brand { color: var(--ink); margin-bottom: 38px; }

@media (max-width: 850px) {
    .topbar-inner { align-items: flex-start; padding: 14px 0; flex-direction: column; gap: 12px; }
    .calendar-layout, .grid-3, .grid-2, .info-layout { grid-template-columns: 1fr; }
    .page-header { align-items: flex-start; flex-direction: column; }
    .user-menu-panel { left: 0; right: auto; }
    .nav { width: 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 3px; scrollbar-width: thin; }
    .nav a, .user-menu { flex: 0 0 auto; }
    .user-menu-panel { position: fixed; top: 96px; right: 12px; left: auto; width: min(205px, calc(100vw - 24px)); }
    h1 { font-size: 2.35rem; }
    .day { min-height: 82px; padding: 5px; }
    .day-status { font-size: .64rem; padding: 4px; }
    .calendar-toolbar { padding: 16px; }
    .weekdays span { font-size: .65rem; padding: 9px 2px; }
    .table-actions { justify-content: flex-start; }
}
