/* ─────────────────────────────────────────────────────────────────────────
   NordTime – system projektowy panelu i aplikacji mobilnej.
   Biznesowa, czytelna kolorystyka; duże przyciski dla pracowników terenowych;
   pełna responsywność (telefon / tablet / komputer); tryb jasny i ciemny.
   ───────────────────────────────────────────────────────────────────────── */
:root {
  --navy-900: #0b1f36;
  --navy-800: #0f2f52;
  --navy-700: #16406e;
  --blue-600: #1d6fd0;
  --blue-500: #2f86e0;
  --blue-100: #e8f1fb;
  --teal-600: #0f8f83;
  --amber-500: #d98b0b;
  --red-600: #c0392b;
  --green-600: #1f8a4c;
  --ink-900: #101a26;
  --ink-700: #33475b;
  --ink-500: #6b7c8f;
  --line: #dbe3ec;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --shadow: 0 1px 2px rgba(16, 26, 38, .06), 0 8px 24px rgba(16, 26, 38, .08);
  --radius: 14px;
  --radius-sm: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --space: 16px;
  --ok: var(--green-600);
  --warn: var(--amber-500);
  --danger: var(--red-600);
}
html[data-theme="dark"] {
  --ink-900: #eef3f9;
  --ink-700: #c3cfdd;
  --ink-500: #93a3b6;
  --line: #26374c;
  --bg: #0b1420;
  --surface: #121e2d;
  --surface-2: #17263a;
  --blue-100: #17304c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink-900); font-family: var(--font); -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; }
.hidden { display: none !important; }
.muted { color: var(--ink-500); }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
a { color: var(--blue-600); }
p { margin: .2em 0 .8em; }

/* ── Ekran startowy ─────────────────────────────────────────────────── */
.boot { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; gap: 14px; color: var(--ink-500); }
.boot-logo { width: 62px; height: 62px; border-radius: 18px; background: var(--navy-800); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 1.4rem; }

/* ── Logowanie ──────────────────────────────────────────────────────── */
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(160deg, var(--navy-900), var(--navy-700) 55%, var(--blue-600)); }
.auth-panel { width: 100%; max-width: 440px; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 26px 22px; }
.auth-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.brand-mark { width: 48px; height: 48px; border-radius: 14px; background: var(--navy-800); color: #fff; display: grid; place-items: center; font-weight: 700; }
.brand-mark.small { width: 34px; height: 34px; border-radius: 10px; font-size: .85rem; }
.auth-brand h1 { font-size: 1.35rem; margin: 0; }
.auth-brand p { margin: 0; font-size: .85rem; color: var(--ink-500); }
.auth-switch { display: flex; justify-content: flex-end; margin: 6px 0 12px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form h2 { font-size: 1.1rem; }
.auth-links { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; margin-top: 4px; }
.auth-message { margin-top: 14px; padding: 10px 12px; border-radius: var(--radius-sm); font-size: .9rem; background: var(--blue-100); }
.auth-message.error { background: #fdecea; color: var(--red-600); }
.auth-message.ok { background: #e7f7ed; color: var(--green-600); }

/* ── Formularze ─────────────────────────────────────────────────────── */
label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--ink-700); font-weight: 500; }
input, select, textarea {
  font: inherit; color: var(--ink-900); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 12px; min-height: 44px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-500); outline-offset: 1px; border-color: var(--blue-500); }
textarea { min-height: 80px; resize: vertical; }
.field-error { color: var(--red-600); font-size: .78rem; }
.checkbox { flex-direction: row; align-items: center; gap: 10px; font-weight: 400; }
.checkbox input { width: auto; min-height: auto; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid { display: grid; gap: 14px; }
@media (max-width: 620px) { .row2, .row3 { grid-template-columns: 1fr; } }

/* ── Przyciski ──────────────────────────────────────────────────────── */
.btn {
  font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 12px 16px; min-height: 46px; cursor: pointer; background: var(--surface-2); color: var(--ink-900);
  transition: transform .04s ease, filter .15s ease; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover { filter: brightness(.97); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--blue-600); color: #fff; }
.btn.success { background: var(--green-600); color: #fff; }
.btn.danger { background: var(--red-600); color: #fff; }
.btn.warning { background: var(--amber-500); color: #24160a; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink-700); }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 7px 11px; font-size: .85rem; }
.btn.large { min-height: 74px; font-size: 1.1rem; border-radius: 16px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--blue-600); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
.icon-btn { position: relative; background: transparent; border: 1px solid var(--line); border-radius: 10px; width: 40px; height: 40px; cursor: pointer; font-size: 1.05rem; color: var(--ink-700); }
.user-chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; cursor: pointer; font: inherit; color: var(--ink-700); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Układ aplikacji ────────────────────────────────────────────────── */
.app-shell { display: grid; grid-template-columns: 258px 1fr; min-height: 100vh; }
.sidebar { background: var(--navy-900); color: #dbe7f5; display: flex; flex-direction: column; padding: 18px 14px; gap: 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar-brand { display: flex; gap: 10px; align-items: center; color: #fff; }
.sidebar-brand span { display: block; font-size: .75rem; color: #9db6d4; }
.nav-main { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-main a { display: flex; align-items: center; gap: 10px; color: #c8d9ec; text-decoration: none; padding: 10px 12px; border-radius: 10px; font-size: .92rem; }
.nav-main a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-main a.active { background: var(--blue-600); color: #fff; font-weight: 600; }
.nav-main .nav-group { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #7f9bbc; margin: 12px 0 4px; padding: 0 12px; }
.sidebar-foot { display: flex; flex-direction: column; gap: 10px; }
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.page-title { margin: 0; font-size: 1.1rem; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.view { padding: 20px 18px 90px; max-width: 1500px; width: 100%; }
.pill { font-size: .75rem; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink-500); border: 1px solid var(--line); }
.pill.offline { background: #fff4e0; color: #8a5a06; border-color: #f0d5a5; }
.badge { position: absolute; top: -4px; right: -4px; background: var(--red-600); color: #fff; font-size: .65rem; border-radius: 999px; padding: 1px 5px; }
.only-mobile { display: none; }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line); display: flex; z-index: 30; padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { flex: 1; text-align: center; padding: 9px 4px; font-size: .68rem; color: var(--ink-500); text-decoration: none; }
.tabbar a.active { color: var(--blue-600); font-weight: 600; }
.tabbar a span.ico { display: block; font-size: 1.2rem; }

@media (max-width: 900px) {
  .only-mobile { display: inline-flex; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; width: 264px; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .view { padding: 14px 12px 110px; }
  .tabbar { display: flex; }
}

/* ── Karty, tabele, listy ───────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h3 { margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.kpi .label { font-size: .78rem; color: var(--ink-500); text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 1.55rem; font-weight: 700; margin-top: 4px; }
.kpi .sub { font-size: .78rem; color: var(--ink-500); }
.kpi.ok .value { color: var(--green-600); }
.kpi.warn .value { color: var(--amber-500); }
.kpi.danger .value { color: var(--red-600); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-500); }
tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: .74rem; font-weight: 600; background: var(--surface-2); color: var(--ink-700); border: 1px solid var(--line); }
.tag.approved { background: #e7f7ed; color: var(--green-600); border-color: #bfe6cd; }
.tag.pending { background: #fff4e0; color: #8a5a06; border-color: #f0d5a5; }
.tag.rejected { background: #fdecea; color: var(--red-600); border-color: #f5c6c2; }
.tag.needs_fix { background: #eef0ff; color: #3b47a8; border-color: #cdd3f5; }
.tag.draft { background: var(--surface-2); }
.tag.working { background: #e7f7ed; color: var(--green-600); }
.tag.break { background: #fff4e0; color: #8a5a06; }
.tag.offline { background: #eceff3; color: var(--ink-500); }
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item h4 { margin: 0 0 2px; font-size: .95rem; }
.list-item .sub { font-size: .8rem; color: var(--ink-500); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--blue-100); color: var(--navy-800); display: grid; place-items: center; font-weight: 700; flex: 0 0 auto; }
.empty { text-align: center; color: var(--ink-500); padding: 26px 12px; }
.hint { font-size: .82rem; color: var(--ink-500); }
.section-title { margin: 22px 0 10px; font-size: .95rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-500); }
.alert { border-radius: var(--radius-sm); padding: 11px 13px; font-size: .88rem; border: 1px solid; margin-bottom: 10px; }
.alert.warning { background: #fff8ec; border-color: #f0d5a5; color: #7a4f06; }
.alert.danger { background: #fdecea; border-color: #f5c6c2; color: #8f2b21; }
.alert.info { background: var(--blue-100); border-color: #c3ddf7; color: var(--navy-700); }
.alert.success { background: #e7f7ed; border-color: #bfe6cd; color: #14663a; }
html[data-theme="dark"] .alert.warning { background: #3a2c12; color: #ffd58a; }
html[data-theme="dark"] .alert.danger { background: #3b1a17; color: #ffb3ab; }
html[data-theme="dark"] .alert.info { background: #17304c; color: #b8d7f7; }
html[data-theme="dark"] .alert.success { background: #123322; color: #9fe0bb; }
html[data-theme="dark"] .tag.approved { background: #123322; color: #9fe0bb; }
html[data-theme="dark"] .tag.rejected { background: #3b1a17; color: #ffb3ab; }

/* ── Ekran pracy (pracownik) ────────────────────────────────────────── */
.work-hero { background: linear-gradient(150deg, var(--navy-800), var(--blue-600)); color: #fff; border-radius: 18px; padding: 20px; }
.work-hero .status-label { font-size: .85rem; opacity: .85; }
.work-hero .status-value { font-size: 1.7rem; font-weight: 700; }
.work-hero .timer { font-variant-numeric: tabular-nums; font-size: 2.4rem; font-weight: 700; letter-spacing: .02em; }
.work-hero .project { opacity: .92; font-size: .95rem; }
.work-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.work-actions .btn.large { width: 100%; }
@media (max-width: 520px) { .work-actions { grid-template-columns: 1fr; } }
.summary-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.summary-tiles .tile { background: rgba(255, 255, 255, .14); border-radius: 12px; padding: 10px; text-align: center; }
.summary-tiles .tile .v { font-size: 1.1rem; font-weight: 700; }
.summary-tiles .tile .l { font-size: .72rem; opacity: .85; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photo-grid img, .photo-grid .doc { width: 100%; height: 96px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); display: grid; place-items: center; font-size: .75rem; color: var(--ink-500); text-align: center; padding: 6px; }
.map-canvas { width: 100%; height: 420px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2); position: relative; overflow: hidden; }
.map-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--ink-500); margin-top: 8px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 8px; }
.chart .bar { flex: 1; background: var(--blue-500); border-radius: 6px 6px 0 0; min-height: 3px; position: relative; }
.chart .bar span { position: absolute; bottom: -20px; left: 0; right: 0; text-align: center; font-size: .62rem; color: var(--ink-500); }
.timeline { display: flex; flex-direction: column; gap: 8px; }
.timeline .row { display: grid; grid-template-columns: 92px 1fr; gap: 10px; align-items: center; font-size: .82rem; }
.timeline .track { height: 22px; background: var(--surface-2); border-radius: 6px; position: relative; border: 1px solid var(--line); }
.timeline .block { position: absolute; top: 0; bottom: 0; background: var(--blue-500); border-radius: 5px; }
.timeline .block.break { background: var(--amber-500); }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar .day { border: 1px solid var(--line); border-radius: 10px; padding: 8px; min-height: 84px; background: var(--surface); font-size: .78rem; }
.calendar .day .d { font-weight: 600; color: var(--ink-500); }
.calendar .day .h { font-size: 1.1rem; font-weight: 700; }
.offline-queue { display: flex; flex-direction: column; gap: 6px; font-size: .82rem; }
.install-banner { position: fixed; left: 12px; right: 12px; bottom: 78px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; gap: 10px; align-items: center; box-shadow: var(--shadow); z-index: 40; font-size: .85rem; }
@media (min-width: 901px) { .install-banner { bottom: 14px; } }

/* ── Modal, toasty ──────────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(9, 17, 28, .55); display: grid; place-items: center; padding: 16px; z-index: 80; }
.modal { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); width: min(680px, 100%); max-height: 92vh; overflow-y: auto; padding: 18px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.toasts { position: fixed; top: 14px; right: 14px; display: flex; flex-direction: column; gap: 8px; z-index: 120; max-width: min(420px, calc(100vw - 28px)); }
.toast { background: var(--surface); border-left: 4px solid var(--blue-600); border-radius: 10px; padding: 11px 13px; box-shadow: var(--shadow); font-size: .88rem; }
.toast.error { border-color: var(--red-600); }
.toast.success { border-color: var(--green-600); }
.toast.warning { border-color: var(--amber-500); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 13px; font: inherit; font-size: .85rem; cursor: pointer; color: var(--ink-700); }
.tabs button.active { background: var(--navy-800); color: #fff; border-color: var(--navy-800); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters label { min-width: 150px; }
.lang-picker { display: flex; gap: 6px; }
.lang-picker button { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 5px 9px; cursor: pointer; font: inherit; font-size: .78rem; color: var(--ink-700); }
.sidebar .lang-picker button { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .18); color: #dbe7f5; }
.lang-picker button.active { background: var(--blue-600); color: #fff; border-color: var(--blue-600); }
.net-status { font-size: .78rem; color: #9db6d4; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--blue-600); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
