:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #eff6ff;
  --green: #16a34a;
  --green-soft: #f0fdf4;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #fff;
  --sidebar: #0f172a;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 380px; background: var(--card); border-radius: 16px; padding: 32px; box-shadow: 0 10px 40px rgba(15, 23, 42, .08); border: 1px solid var(--line); }
.login-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-card .brand img { width: 40px; height: 40px; border-radius: 10px; }
.login-card h1 { font-size: 18px; }
.login-card p { color: var(--muted); margin: 2px 0 0; font-size: 13px; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 290px 1fr; height: 100vh; }
.sidebar { background: var(--sidebar); color: #cbd5e1; display: flex; flex-direction: column; min-height: 0; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; color: #fff; }
.sidebar .brand img { width: 32px; height: 32px; border-radius: 8px; }
.sidebar .brand strong { font-size: 15px; }
.sidebar .brand span { display: block; font-size: 11px; color: #94a3b8; }
.sidebar .new-client { margin: 0 16px 12px; }
.sidebar .search { margin: 0 16px 8px; }
.sidebar .search input { width: 100%; padding: 9px 12px; border-radius: 8px; border: 1px solid #1e293b; background: #1e293b; color: #e2e8f0; outline: none; }
.sidebar .search input::placeholder { color: #64748b; }
.sidebar .section-label { padding: 12px 20px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #64748b; font-weight: 600; }
.client-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.client-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; cursor: pointer; color: #cbd5e1; }
.client-item:hover { background: #1e293b; }
.client-item.active { background: #1e3a8a; color: #fff; }
.client-item .avatar { width: 30px; height: 30px; border-radius: 8px; background: #334155; display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #fff; flex: 0 0 auto; }
.client-item.active .avatar { background: var(--blue); }
.client-item .meta { min-width: 0; flex: 1; }
.client-item .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-item .sub { font-size: 11.5px; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-item .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.dot.on { background: #22c55e; }
.dot.off { background: #64748b; }
.sidebar .footer { border-top: 1px solid #1e293b; padding: 10px 8px; }
.sidebar .footer a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #cbd5e1; cursor: pointer; }
.sidebar .footer a:hover, .sidebar .footer a.active { background: #1e293b; color: #fff; }
.sidebar .empty { padding: 16px 20px; color: #64748b; font-size: 13px; }

.main { overflow-y: auto; min-width: 0; }
.page { max-width: 1180px; margin: 0 auto; padding: 28px 36px 60px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-header h1 { font-size: 22px; letter-spacing: -.01em; }
.page-header .sub { color: var(--muted); margin-top: 4px; }
.page-header .actions { display: flex; gap: 8px; align-items: center; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.tab { padding: 10px 14px; border: none; background: none; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
.grid.side { grid-template-columns: 1.3fr 1fr; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card h3 { font-size: 15px; margin-bottom: 4px; }
.card .desc { color: var(--muted); margin: 0 0 16px; font-size: 13px; line-height: 1.5; }
.card + .card { margin-top: 0; }
.stack > * + * { margin-top: 16px; }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 600; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.45; }
.input, .field input:not([type=checkbox]), .field select, .field textarea {
  width: 100%; padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; outline: none;
}
.field textarea { resize: vertical; min-height: 76px; line-height: 1.45; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 8px; border: 1px solid transparent; font-weight: 600; cursor: pointer; white-space: nowrap; line-height: 1.2; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); }
.btn-secondary { background: #fff; border-color: #cbd5e1; color: var(--ink-2); }
.btn-secondary:hover:not(:disabled) { background: #f8fafc; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); background: #f1f5f9; }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-success { background: #fff; border-color: #bbf7d0; color: var(--green); }
.btn-success:hover { background: var(--green-soft); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.sidebar .btn-primary { width: 100%; padding: 10px; }

/* ---------- Toggle ---------- */
.toggle-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.toggle-row:last-child { border-bottom: none; }
.toggle-row .title { font-weight: 600; }
.toggle-row .text { color: var(--muted); font-size: 13px; margin-top: 2px; line-height: 1.45; }
.switch { position: relative; display: inline-block; vertical-align: middle; width: 40px; height: 22px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; cursor: pointer; transition: .15s; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::before { transform: translateX(18px); }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #f8fafc; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.pending { background: var(--amber-soft); color: var(--amber); }
.badge.confirmed { background: var(--blue-soft); color: var(--blue-dark); }
.badge.completed { background: var(--green-soft); color: var(--green); }
.badge.cancelled { background: var(--red-soft); color: var(--red); }
.badge.neutral { background: #f1f5f9; color: var(--ink-2); }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }

/* ---------- Link box ---------- */
.linkbox { display: flex; gap: 8px; align-items: center; }
.linkbox code { flex: 1; min-width: 0; padding: 9px 12px; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ---------- Checklist ---------- */
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.checklist .ico { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: 0 0 auto; }
.checklist .ico.ok { background: var(--green-soft); color: var(--green); }
.checklist .ico.no { background: var(--amber-soft); color: var(--amber); }
.checklist a { margin-left: auto; font-size: 12.5px; font-weight: 600; cursor: pointer; }

/* ---------- Working hours ---------- */
.wh { display: grid; grid-template-columns: 90px 1fr auto; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.wh:last-child { border-bottom: none; }
.wh .day { font-weight: 600; }
.wh .times { display: flex; align-items: center; gap: 8px; }
.wh .times input { width: 130px; padding: 7px 10px; border: 1px solid #cbd5e1; border-radius: 8px; }
.wh .times.closed { opacity: .35; pointer-events: none; }
.wh label.closed-label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); cursor: pointer; }

/* ---------- Info boxes ---------- */
.info { background: var(--blue-soft); border: 1px solid #bfdbfe; color: #1e3a8a; padding: 12px 14px; border-radius: 10px; font-size: 13px; line-height: 1.5; }
.info.warn { background: var(--amber-soft); border-color: #fde68a; color: #78350f; }
.info code { background: rgba(255,255,255,.7); padding: 1px 5px; border-radius: 4px; }
.placeholders { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.placeholders code { background: #f1f5f9; border: 1px solid var(--line); padding: 2px 6px; border-radius: 5px; cursor: pointer; }
.placeholders code:hover { border-color: var(--blue); color: var(--blue); }

/* ---------- Empty / loading ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state .big { font-size: 40px; margin-bottom: 10px; }
.empty-state h2 { color: var(--ink); font-size: 18px; margin-bottom: 6px; }
.loading { display: grid; place-items: center; padding: 80px 0; }
.spinner { width: 26px; height: 26px; border: 3px solid #dbeafe; border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; }
.btn .spinner { width: 14px; height: 14px; border-width: 2px; border-color: rgba(255,255,255,.4); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { width: 520px; max-width: 100%; background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal header { padding: 20px 24px 0; }
.modal header h2 { font-size: 17px; }
.modal header p { color: var(--muted); margin: 4px 0 0; font-size: 13px; }
.modal .body { padding: 20px 24px 8px; }
.modal footer { padding: 12px 24px 20px; display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; right: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 380px; animation: tin .18s ease; }
.toast.success { background: #15803d; }
.toast.error { background: #b91c1c; }
@keyframes tin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (max-width: 1100px) {
  .grid.cols-5 { grid-template-columns: repeat(3, 1fr); }
  .grid.side, .grid.cols-2 { grid-template-columns: 1fr; }
}
