:root {
  --bg: #f8fafc; --card: #ffffff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --brand: #f97316; --brand-dark: #ea580c; --brand-soft: #ffedd5;
  --ok: #16a34a; --warn: #d97706; --bad: #dc2626; --info: #2563eb;
  --radius: 12px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--info); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 17px; margin: 0 0 8px; }
h3 { font-size: 14px; margin: 0 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.hidden { display: none !important; }

/* layout */
#app { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #fff; border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; font-weight: 700; font-size: 17px; }
.brand img { width: 32px; height: 32px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--text); font-weight: 500; }
.nav a:hover { background: var(--bg); }
.nav a.active { background: var(--brand-soft); color: var(--brand-dark); }
.nav .badge { margin-left: auto; }
.sidebar .me { margin-top: auto; padding: 10px 8px; border-top: 1px solid var(--line); font-size: 13px; }
.main { flex: 1; padding: 20px 24px 90px; max-width: 1400px; width: 100%; }
.topbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.tabbar { display: none; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { padding: 14px 12px 84px; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 50; }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 0; position: relative; }
  .tabbar a.active { color: var(--brand-dark); }
  .tabbar a .ico { font-size: 20px; }
  .tabbar .badge { position: absolute; top: 0; right: calc(50% - 22px); }
}

/* cards & tables */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .num { font-size: 28px; font-weight: 700; line-height: 1.1; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr:hover td { background: #fafbfc; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* badges / pills */
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--brand); color: #fff; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #f1f5f9; color: var(--muted); }
.pill.ok { background: #dcfce7; color: #166534; }
.pill.warn { background: #fef3c7; color: #92400e; }
.pill.bad { background: #fee2e2; color: #991b1b; }
.pill.info { background: #dbeafe; color: #1e40af; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-weight: 600; font-size: 14px; }
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.xl { padding: 18px 24px; font-size: 18px; border-radius: 16px; justify-content: center; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=datetime-local], input[type=tel], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.field { margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); margin: 6px 0; }
.check input { width: 18px; height: 18px; }
select.inline { width: auto; padding: 6px 28px 6px 10px; }

/* planning */
.planning { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); }
.pgrid { display: grid; grid-template-columns: 170px repeat(7, minmax(130px, 1fr)) 70px; min-width: 1100px; }
.pgrid > div { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 6px; min-height: 48px; }
.pgrid .head { background: #f8fafc; font-weight: 600; font-size: 13px; position: sticky; top: 0; z-index: 2; }
.pgrid .head.today { color: var(--brand-dark); }
.pgrid .rowhead { background: #fafbfc; font-weight: 600; font-size: 13px; position: sticky; left: 0; z-index: 1; }
.pgrid .rowhead .sub { font-weight: 400; color: var(--muted); font-size: 12px; }
.pgrid .cell { cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.pgrid .cell:hover { background: #fffaf5; }
.pgrid .total { font-weight: 600; text-align: right; font-size: 13px; color: var(--muted); }
.pgrid .footer { background: #f8fafc; font-weight: 600; font-size: 13px; }
.shift { border-left: 4px solid var(--brand); background: #fff7ed; border-radius: 7px; padding: 4px 6px; font-size: 12px; line-height: 1.3; cursor: pointer; }
.shift:hover { filter: brightness(.97); }
.shift .t { font-weight: 700; }
.shift .n { color: var(--text); }
.shift.draft { border-style: dashed; opacity: .85; background: repeating-linear-gradient(135deg, #fff, #fff 6px, #fff7ed 6px, #fff7ed 12px); }
.shift.open { background: #eff6ff; border-color: var(--info); }
.shift.training { background: #fefce8; border-color: #ca8a04; }
.shift.oncall { background: #fef2f2; border-color: var(--bad); }
.shift.off { background: #f1f5f9; border-color: #94a3b8; color: var(--muted); }
.shift.mine { box-shadow: inset 0 0 0 1px var(--brand); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }

/* mobile planning list */
.daylist .day { margin-bottom: 14px; }
.daylist .day h2 { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.daylist .shift { font-size: 14px; padding: 8px 10px; margin-bottom: 6px; }

/* clock */
.clock { max-width: 480px; margin: 0 auto; text-align: center; }
.clock .time { font-size: 54px; font-weight: 700; letter-spacing: -1px; margin: 12px 0 2px; }
.clock .btns { display: grid; gap: 10px; margin-top: 18px; }
.clock .state { padding: 10px; border-radius: 12px; background: #f1f5f9; margin-top: 10px; }
.clock .state.in { background: #dcfce7; color: #166534; }
.clock .state.pause { background: #fef3c7; color: #92400e; }

/* modal */
#modal-root:empty { display: none; }
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 100; padding: 0; }
.modal { background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 18px 18px 24px; animation: up .18s ease-out; }
@media (min-width: 640px) { .overlay { align-items: center; padding: 20px; } .modal { border-radius: 18px; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h2 { margin-bottom: 14px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.modal .actions .left { margin-right: auto; }

/* toast */
#toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 200; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.bad { background: var(--bad); }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; width: 100%; }
.login .card { width: 100%; max-width: 380px; }
.login .brand { justify-content: center; font-size: 22px; padding-bottom: 8px; }
.companies { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 0 0 18px; }
.company { display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; background: color-mix(in srgb, var(--c) 12%, white); color: color-mix(in srgb, var(--c) 75%, black); border: 1px solid color-mix(in srgb, var(--c) 30%, white); }
.login h2 { text-align: center; }

.alert { padding: 10px 12px; border-radius: 10px; background: #fef3c7; color: #92400e; font-size: 14px; margin-bottom: 12px; }
.alert.info { background: #dbeafe; color: #1e40af; }
.alert.bad { background: #fee2e2; color: #991b1b; }
.list-item { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #f1f5f9; color: var(--text); }
.chip.mgr { background: #ffedd5; color: var(--brand-dark); font-weight: 600; }
.site-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.site-tabs button { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-weight: 600; font-size: 13px; }
.site-tabs button.active { background: var(--text); color: #fff; border-color: var(--text); }
