:root {
  --ink: #17212b;
  --muted: #687582;
  --line: #dfe5e9;
  --canvas: #f4f6f7;
  --panel: #ffffff;
  --sidebar: #18222c;
  --sidebar-soft: #24313d;
  --primary: #176b55;
  --primary-hover: #125a47;
  --blue: #2f6f9f;
  --danger: #b33a43;
  --warning: #a76a12;
  --radius: 7px;
  --shadow: 0 8px 24px rgba(20, 32, 43, .07);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: "Segoe UI", Arial, sans-serif; letter-spacing: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
button, input, select, textarea { letter-spacing: 0; }
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 248px; z-index: 1040; display: flex; flex-direction: column; background: var(--sidebar); color: white; border-right: 1px solid rgba(255,255,255,.06); }
.sidebar-brand { min-height: 82px; display: flex; align-items: center; gap: 12px; padding: 18px 20px; color: white; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-brand:hover { color: white; background: rgba(255,255,255,.03); }
.sidebar-brand img { width: 40px; height: 40px; object-fit: contain; background: white; border-radius: 5px; padding: 3px; }
.brand-mark { width: 40px; height: 40px; display: inline-grid; place-items: center; flex: 0 0 40px; border-radius: 5px; background: #e9f4ef; color: var(--primary); font: 700 21px/1 "Bahnschrift", "Segoe UI", sans-serif; }
.sidebar-brand span { min-width: 0; display: flex; flex-direction: column; }
.sidebar-brand b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.sidebar-brand small, .sidebar-footer small { color: rgba(255,255,255,.55); font-size: 11px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 10px; }
.sidebar-link { height: 42px; display: flex; align-items: center; gap: 12px; padding: 0 12px; margin: 2px 0; border-radius: 5px; color: rgba(255,255,255,.72); font-size: 14px; font-weight: 500; transition: background .16s ease, color .16s ease, transform .16s ease; }
.sidebar-link svg { width: 18px; height: 18px; flex: 0 0 18px; }
.sidebar-link:hover { color: white; background: rgba(255,255,255,.07); transform: translateX(2px); }
.sidebar-link.active { color: white; background: #27654f; box-shadow: inset 3px 0 #7ac7a9; }
.sidebar-footer { min-height: 72px; display: flex; align-items: center; gap: 11px; padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-footer > div:nth-child(2) { min-width: 0; display: flex; flex-direction: column; }
.sidebar-footer b { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.user-avatar { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 50%; background: #d8eee5; color: #155b48; font-weight: 700; }
.app-main { min-height: 100vh; margin-left: 248px; }
.topbar { position: sticky; top: 0; z-index: 1020; height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 0 28px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.topbar-left, .topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar h1 { margin: 0; font-size: 18px; line-height: 1.2; font-weight: 650; }
.topbar-eyebrow { display: none; color: var(--muted); font-size: 11px; }
.content { width: 100%; max-width: 1680px; margin: 0 auto; padding: 26px 28px 42px; }
.sidebar-toggle { display: none !important; }
.sidebar-overlay { display: none; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 5px; background: white; color: #53616d; padding: 0; transition: background .15s ease, color .15s ease, border-color .15s ease, transform .15s ease; }
.icon-btn:hover { color: var(--ink); background: #f2f5f6; border-color: #cfd8dd; transform: translateY(-1px); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.danger { color: var(--danger); }
.icon-btn.success { color: var(--primary); }
.sync-chip { min-height: 36px; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 5px; padding: 0 12px; background: white; color: var(--muted); font-size: 12px; font-weight: 650; transition: background .15s ease, border-color .15s ease; }
.sync-chip svg { width: 16px; height: 16px; }
.sync-chip.ok { color: #176b55; background: #eef8f4; border-color: #bfe2d4; }
.sync-chip.offline { color: #a22e39; background: #fff2f2; border-color: #edc6ca; }
.sync-chip.pending, .sync-chip.syncing { color: #8a580d; background: #fff7e9; border-color: #ead4aa; }
.sync-chip.syncing svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.page-heading h1 { margin: 0 0 4px; font-size: 25px; font-weight: 680; }
.page-heading p, .panel-header p { margin: 0; color: var(--muted); font-size: 13px; }
.worker-profile-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.worker-profile-head h4 { min-width: 280px; flex: 1; }
.worker-profile-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.report-period { display: grid; grid-template-columns: 130px 96px auto; gap: 8px; }
.report-period .form-select { width: 100%; min-width: 0; }
.sync-banner { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; padding: 13px 15px; border: 1px solid; border-radius: 6px; }
.sync-banner svg { width: 21px; height: 21px; flex: 0 0 21px; }
.sync-banner div { display: flex; flex-direction: column; }
.sync-banner span { font-size: 12px; }
.sync-banner.offline { color: #912d37; background: #fff1f2; border-color: #edc6ca; }
.sync-banner.pending { color: #80520c; background: #fff7e8; border-color: #ead3a7; }
.metric-card .card-body { min-height: 104px; display: flex; align-items: center; gap: 15px; }
.metric-icon { width: 43px; height: 43px; display: grid; place-items: center; flex: 0 0 43px; border-radius: 6px; }
.metric-icon svg { width: 21px; height: 21px; }
.metric-icon.blue { color: #2b6996; background: #e7f0f7; }
.metric-icon.green { color: #176b55; background: #e5f3ed; }
.metric-icon.amber { color: #93600f; background: #fff0d4; }
.metric-icon.red { color: #a22e39; background: #fbe7e9; }
.metric-icon.neutral { color: #60707c; background: #edf1f3; }
.metric-value { font: 680 29px/1.05 "Bahnschrift", "Segoe UI", sans-serif; }
.metric-label { margin-top: 5px; color: var(--muted); font-size: 12px; }
.content-grid { display: grid; gap: 18px; }
.schedule-grid { grid-template-columns: minmax(330px, .8fr) minmax(620px, 1.7fr); align-items: start; }
.device-grid { grid-template-columns: minmax(300px, .6fr) minmax(680px, 1.8fr); align-items: start; }
.panel, .card { background: var(--panel); border: 1px solid var(--line) !important; border-radius: var(--radius) !important; box-shadow: var(--shadow); overflow: hidden; }
.panel-header { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0 0 3px; font-size: 16px; font-weight: 680; }
.panel-body { padding: 18px; }
.card-body { padding: 18px; }
.card h4, .card h5, .card h6 { font-weight: 670; }

.btn { min-height: 38px; border-radius: 5px; font-weight: 620; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary, .btn-dark { color: white; background: var(--primary); border-color: var(--primary); }
.btn-primary:hover, .btn-dark:hover { color: white; background: var(--primary-hover); border-color: var(--primary-hover); box-shadow: 0 5px 13px rgba(23,107,85,.2); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-light { border-color: var(--line); background: #f7f8f9; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.45); border-top-color: white; border-radius: 50%; animation: spin .7s linear infinite; }
.form-label { color: #3f4c57; font-size: 12px; font-weight: 650; }
.form-control, .form-select { min-height: 40px; border-color: #d3dce1; border-radius: 5px; font-size: 13px; box-shadow: none !important; }
.form-control:focus, .form-select:focus { border-color: #5a9b85; box-shadow: 0 0 0 3px rgba(23,107,85,.1) !important; }
.form-control-color { width: 58px; padding: 4px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 6px; background: #fafbfb; }
.setting-row > div { display: flex; flex-direction: column; }
.setting-row small { color: var(--muted); font-size: 11px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { position: relative; display: block; width: 44px; height: 24px; border-radius: 14px; background: #b8c2c8; cursor: pointer; transition: background .18s ease; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: white; box-shadow: 0 1px 4px rgba(0,0,0,.22); transition: transform .18s ease; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(20px); }

.table { --bs-table-bg: transparent; color: var(--ink); }
.data-table, .table { font-size: 12.5px; }
.data-table thead th, .table thead th { height: 44px; vertical-align: middle; color: #64717c; background: #f8f9fa; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.data-table td, .table td { padding: 10px 11px; vertical-align: middle; border-color: #e8edef; }
.data-table tbody tr, .table-hover tbody tr { transition: background .14s ease; }
.data-table tbody tr:hover, .table-hover tbody tr:hover { background: #f7faf9; }
.data-table td small { display: block; color: var(--muted); margin-top: 2px; }
.action-cell { white-space: nowrap; }
.empty-state { padding: 36px !important; text-align: center; color: var(--muted) !important; }
.muted, .text-muted { color: var(--muted) !important; }
.status-pill, .badge { display: inline-flex; align-items: center; border-radius: 12px; padding: 4px 8px; font-size: 10px; font-weight: 700; }
.status-pill.success { color: #176b55; background: #e7f5ef; }
.status-pill.warning { color: #8b590e; background: #fff1d7; }
.status-pill.danger { color: #a22e39; background: #fde9eb; }
.status-pill.info { color: #225d87; background: #e7f1f8; }
.status-pill.neutral { color: #596772; background: #edf0f2; }
.alert { border: 1px solid transparent; border-radius: 6px; font-size: 13px; box-shadow: 0 5px 18px rgba(20,32,43,.05); }
.pairing-alert { font-family: Consolas, monospace; overflow-wrap: anywhere; }
.modal-content { border: 0; border-radius: 7px; box-shadow: 0 22px 70px rgba(20,32,43,.22); }

.worker-search { position: relative; }
.worker-search > svg { position: absolute; left: 12px; top: 50%; z-index: 1; width: 17px; height: 17px; color: #71808b; transform: translateY(-50%); pointer-events: none; }
.worker-search .form-control { padding-left: 38px; padding-right: 42px; }
.worker-search-clear { position: absolute; right: 5px; top: 50%; width: 32px; height: 32px; display: grid; place-items: center; padding: 0; border: 0; background: transparent; color: #66747f; transform: translateY(-50%); }
.worker-search-clear:hover { color: var(--ink); background: #eef2f3; }
.worker-search-clear svg { width: 16px; height: 16px; }
.worker-picker { max-height: 290px; min-height: 82px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; background: #fbfcfc; }
.worker-picker-empty { padding: 13px 11px; color: var(--muted); font-size: 11px; border-bottom: 1px solid #edf0f1; }
.worker-option { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 7px 11px; border-bottom: 1px solid #edf0f1; cursor: pointer; }
.worker-option[hidden] { display: none !important; }
.worker-option:hover { background: #f1f7f5; }
.worker-option span { display: flex; flex-direction: column; font-size: 12px; }
.worker-option small { color: var(--muted); font-size: 10px; }

.kalendar-tabela { font-size: 11px; }
.kalendar-tabela td, .kalendar-tabela th { padding: 5px 6px; white-space: nowrap; }
.sticky-col { position: sticky; left: 0; z-index: 2; min-width: 170px; background: white !important; }
thead .sticky-col { background: #f8f9fa !important; }
.cell-go { background: #dff0f7 !important; font-weight: 700; }
.cell-otvoren { background: #f9e0e3 !important; font-weight: 700; }
.cell-kasnio { background: #fff0d1 !important; }

.install-page, .login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #eef2f3; }
.install-shell, .login-shell { width: min(460px, 100%); }
.install-brand, .login-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 18px; }
.install-brand > div, .login-brand > div { display: flex; flex-direction: column; }
.install-brand small, .login-brand small { color: var(--muted); font-size: 11px; }
.install-panel, .login-panel { padding: 28px; background: white; border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 16px 45px rgba(20,32,43,.1); }
.install-panel h1, .login-panel h1 { margin: 0 0 18px; font-size: 22px; }

@media (max-width: 1180px) {
  .schedule-grid, .device-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-overlay { position: fixed; inset: 0; z-index: 1035; background: rgba(12,19,25,.45); }
  .sidebar-open .sidebar-overlay { display: block; }
  .app-main { margin-left: 0; }
  .sidebar-toggle { display: inline-grid !important; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px 34px; }
}
@media (max-width: 560px) {
  .sync-chip { width: 36px; padding: 0; justify-content: center; }
  .sync-chip span { display: none; }
  .topbar h1 { font-size: 16px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .page-heading h1 { font-size: 21px; }
  .content { padding-inline: 11px; }
  .card-body, .panel-body { padding: 14px; }
  .worker-profile-actions { width: 100%; justify-content: stretch; }
  .worker-profile-actions > .btn { width: 100%; }
  .report-period { width: 100%; grid-template-columns: minmax(0, 1fr) 94px; }
  .report-period .btn { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
