:root {
    --accent: #0f766e;
    --bg: #f5f6f8;
    --card: #ffffff;
    --text: #1f2328;
    --muted: #667085;
    --border: #e4e7ec;
    --danger: #b42318;
    --danger-bg: #fef3f2;
    --ok-bg: #ecfdf3;
    --ok: #067647;
    --radius: 10px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.5; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .75rem; }

.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.5rem; padding: .75rem 1rem; background: var(--card); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 600; color: var(--text); text-decoration: none; }
.brand img { height: 32px; width: auto; }
.nav { display: flex; flex-wrap: wrap; gap: .25rem; flex: 1; }
.nav a { padding: .4rem .7rem; border-radius: 8px; color: var(--muted); text-decoration: none; }
.nav a:hover { background: var(--bg); color: var(--text); }
.nav a.active { background: var(--accent); color: #fff; }
.user { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.user form { margin: 0; }
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.form { display: grid; gap: .9rem; max-width: 640px; }
.form label { display: grid; gap: .3rem; font-size: .9rem; color: var(--muted); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .9rem; }
input, select, textarea { font: inherit; color: var(--text); padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; width: 100%; }
input[type=color] { padding: .2rem; height: 2.5rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.btn, button { font: inherit; cursor: pointer; display: inline-block; padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #fff; text-decoration: none; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-danger { background: #fff; color: var(--danger); border-color: var(--danger); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; }
.btn-sm { padding: .3rem .6rem; font-size: .85rem; }

.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--danger-bg); color: var(--danger); }
.muted { color: var(--muted); font-size: .9rem; }

table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.inline { display: inline-flex; gap: .4rem; align-items: center; margin: 0; }
.inline input { width: auto; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; background: var(--bg); color: var(--muted); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-off { background: var(--danger-bg); color: var(--danger); }

.checks { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .35rem; }
.checks li::before { content: "✓ "; color: var(--ok); font-weight: 700; }
.checks li.fail::before { content: "✕ "; color: var(--danger); }
.checks .hint { display: block; margin-left: 1.2rem; color: var(--danger); font-size: .85rem; }

body.bare { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.bare-card { width: 100%; max-width: 560px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 2rem 1.5rem; }
.bare-brand { display: flex; align-items: center; justify-content: center; gap: .6rem; font-weight: 700; font-size: 1.2rem; margin-bottom: 1.5rem; }
.bare-brand img { height: 48px; width: auto; }
.bare-card .form { max-width: none; }
.error-page { text-align: center; }
.error-code { font-size: 3rem; font-weight: 700; color: var(--accent); }
.logo-preview { max-height: 64px; max-width: 200px; border: 1px solid var(--border); border-radius: 8px; padding: .25rem; background: #fff; }

@media (max-width: 640px) {
    .user { width: 100%; justify-content: space-between; }
    .container { padding-top: 1rem; }
}

/* Филиалы: карта геозоны */
.map { height: 360px; border-radius: var(--radius); border: 1px solid var(--border); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; display: grid; gap: .9rem; }
legend { padding: 0 .4rem; color: var(--muted); font-size: .9rem; }
.check { display: flex !important; align-items: center; gap: .5rem; color: var(--text) !important; }
.check input { width: auto; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
code.url { word-break: break-all; font-size: .85rem; background: var(--bg); padding: .2rem .4rem; border-radius: 6px; }

/* Сотрудники: недельный график */
.schedule td { padding: .4rem .5rem; }
.schedule input[type=time] { width: 8rem; }

/* Лист с QR для печати */
body.print-page { background: #fff; }
.print-toolbar { display: flex; gap: .5rem; justify-content: center; padding: 1rem; }
.qr-sheet { max-width: 180mm; margin: 0 auto; padding: 10mm; text-align: center; }
.qr-brand { display: flex; align-items: center; justify-content: center; gap: .75rem; font-size: 1.4rem; font-weight: 700; }
.qr-brand img { height: 56px; width: auto; }
.qr-sheet h1 { font-size: 2rem; margin: 8mm 0 2mm; }
.qr-branch { font-size: 1.3rem; color: var(--accent); font-weight: 600; }
.qr-code { width: 120mm; max-width: 100%; margin: 8mm auto; }
.qr-code svg { width: 100%; height: auto; display: block; }
.qr-steps { text-align: left; display: inline-block; font-size: 1.1rem; margin: 0; }
@page { size: A4; margin: 10mm; }
@media print { .no-print { display: none !important; } }

/* Страницы сотрудника (телефон) */
body.employee { min-height: 100vh; }
.phone { max-width: 480px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.phone-brand { display: flex; align-items: center; justify-content: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; margin-bottom: 1.25rem; }
.phone-brand img { height: 40px; width: auto; }
.btn-wide { width: 100%; padding: 1rem; font-size: 1.1rem; border-radius: 12px; }
.status { margin-top: 1rem; min-height: 1.5rem; text-align: center; }
.status-ok { background: var(--ok-bg); color: var(--ok); padding: 1rem; border-radius: 12px; font-size: 1.2rem; font-weight: 600; }
.status-error { background: var(--danger-bg); color: var(--danger); padding: 1rem; border-radius: 12px; }
.status-wait { background: #fffaeb; color: #93370d; padding: 1rem; border-radius: 12px; }
.punch { text-align: center; }
.punch-branch { font-size: 1.3rem; font-weight: 600; color: var(--accent); }
.punch-time { font-size: 3.5rem; font-weight: 700; letter-spacing: .02em; line-height: 1.1; margin: .25rem 0; }
.punch-buttons { display: grid; gap: .75rem; margin-top: 1.5rem; }
.punch-btn { padding: 1.4rem 1rem; font-size: 1.4rem; font-weight: 600; border-radius: 14px; }
button:disabled { opacity: .55; cursor: default; }
.day { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .75rem; overflow: hidden; }
.day-title { padding: .5rem .9rem; background: var(--bg); font-weight: 600; font-size: .9rem; }
.day-row { display: grid; grid-template-columns: 3.5rem 4.5rem 1fr; gap: .5rem; padding: .55rem .9rem; border-top: 1px solid var(--border); }
.day-row.cancelled { text-decoration: line-through; opacity: .6; }
.day-time { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Сегодня */
.alerts { margin-bottom: 1rem; }
.today-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; align-items: start; }
.today-card h2 { margin-top: 0; display: flex; align-items: center; gap: .5rem; }
.today-card .count { font-size: .85rem; background: var(--bg); color: var(--muted); border-radius: 999px; padding: 0 .5rem; }
.today-warn { border-left: 4px solid var(--danger); }
.today-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }

/* Журнал, запросы */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tabs a { padding: .5rem .9rem; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }
.filters label { display: grid; gap: .25rem; font-size: .85rem; color: var(--muted); }
.filters input, .filters select { width: auto; min-width: 9rem; }
.nowrap { white-space: nowrap; }
tr.cancelled td { color: var(--muted); }
tr.cancelled td:nth-child(-n+4) { text-decoration: line-through; }
.cancel-note { color: var(--danger); font-size: .85rem; text-decoration: none; }
.inline-details summary { cursor: pointer; color: var(--accent); font-size: .9rem; }
.inline-details form { margin-top: .4rem; }
.inline-details input { min-width: 12rem; }
.forgot summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.forgot[open] summary { margin-bottom: .5rem; }
.request { padding: .75rem 1rem; display: grid; gap: .25rem; }
textarea { resize: vertical; }
.filters input[type=checkbox] { min-width: 0; width: auto; }

/* Табель */
.timesheet-bar { margin-bottom: 1rem; }
.timesheet-bar input[type=month], .timesheet-bar select { width: auto; }
table.timesheet { font-size: .85rem; }
table.timesheet th, table.timesheet td { padding: .35rem .3rem; text-align: center; border-right: 1px solid var(--border); }
table.timesheet .ts-name { text-align: left; min-width: 11rem; position: sticky; left: 0; background: var(--card); z-index: 1; }
table.timesheet .ts-name small { display: block; }
.ts-day small { display: block; font-weight: 400; text-transform: none; }
table.timesheet .weekend { background: #f2f4f7; }
.ts-cell a { color: inherit; text-decoration: none; display: block; }
.ts-cell a:hover { text-decoration: underline; }
.ts-absent { background: var(--danger-bg) !important; color: var(--danger); font-weight: 600; }
.ts-unpaired { background: #ffe8b3 !important; color: #93370d; font-weight: 600; }
.ts-deviation { background: #fff4cc !important; }
.ts-open { color: var(--accent); font-weight: 700; }
.ts-off { color: var(--muted); }
.ts-total { background: var(--bg); }
.legend span { padding: 0 .25rem; border-radius: 4px; }
