:root {
    --bg:       #0e0f12;
    --surface:  #16181d;
    --surface2: #1c1f26;
    --line:     #262a33;
    --text:     #e9ebef;
    --muted:    #8b919d;
    --accent:   #c8f24c;
    --accent-t: #14170c;
    --danger:   #ff6b6b;
    --ok:       #56d68a;
    --warn:     #f5b942;
    --r:        14px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ------------------------------------------------------------ topbar */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: max(12px, env(safe-area-inset-top)) 16px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    font-weight: 700;
    letter-spacing: -0.02em;
    font-size: 17px;
}

.topnav {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.topnav a {
    font-size: 13px;
    color: var(--muted);
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid transparent;
}

.topnav a.on {
    color: var(--text);
    border-color: var(--line);
    background: var(--surface);
}

/* ------------------------------------------------------------ layout */

.wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px 16px calc(40px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 16px;
}

h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 15px; margin: 0 0 12px; letter-spacing: -0.01em; }

.sub { color: var(--muted); font-size: 13px; margin: 0; }

.flash {
    background: var(--surface2);
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 14px;
}

/* ------------------------------------------------------------ licznik */

.timer-card { text-align: center; padding: 26px 16px; }

.timer {
    font-size: clamp(44px, 15vw, 64px);
    font-weight: 700;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    line-height: 1.05;
    margin: 0;
}

.timer-task {
    color: var(--muted);
    font-size: 14px;
    margin: 6px 0 20px;
}

.live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ok);
    margin-right: 7px;
    vertical-align: middle;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

@media (prefers-reduced-motion: reduce) {
    .live-dot { animation: none; }
}

/* ------------------------------------------------------------ przyciski */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 15px 18px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface2);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
}

.btn:active { transform: translateY(1px); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-t); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #1a0d0d; }
.btn-ghost  { background: transparent; color: var(--muted); }
.btn-sm     { width: auto; padding: 8px 14px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.task-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

@media (min-width: 480px) {
    .task-grid { grid-template-columns: 1fr 1fr; }
}

.task-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    padding: 14px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface2);
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.task-btn:hover, .task-btn:active {
    border-color: var(--accent);
    background: #1f2229;
}

.task-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: rgba(200, 242, 76, 0.09);
    color: var(--accent);
    flex-shrink: 0;
}

.task-ico svg { width: 20px; height: 20px; display: block; }

.task-label {
    flex: 1;
    min-width: 0;
}

.task-play {
    width: 20px;
    height: 20px;
    color: var(--muted);
    flex-shrink: 0;
    transition: color .15s, transform .15s;
}

.task-btn:hover .task-play { color: var(--accent); transform: translateX(2px); }

/* ------------------------------------------------------------ statystyki */

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 10px;
    text-align: center;
}

.stat-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 3px; }

.bar {
    height: 6px;
    border-radius: 99px;
    background: var(--surface2);
    overflow: hidden;
    margin-top: 10px;
}

.bar span { display: block; height: 100%; background: var(--accent); }
.bar.over span { background: var(--warn); }

/* ------------------------------------------------------------ listy */

.entry {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.entry:last-child { border-bottom: 0; }
.entry-main { min-width: 0; flex: 1; }
.entry-title { font-size: 14px; font-weight: 600; }
.entry-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.entry-note { color: var(--muted); font-size: 12px; margin-top: 4px; word-break: break-word; }
.entry-time { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.entry-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.entry-del {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--muted);
    width: 30px;
    height: 30px;
    border-radius: 8px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.entry-del:hover { color: var(--danger); border-color: rgba(255,107,107,0.5); }

/* ------------------------------------------------------------ hero pracownika */

.hero {
    text-align: center;
    padding: 8px 0 4px;
}

.hero-hello {
    font-size: 15px;
    color: var(--muted);
    margin: 0 0 2px;
}

.hero-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
}

.help {
    background: transparent;
    border: 1px dashed var(--line);
    border-radius: var(--r);
    padding: 14px 16px;
    color: var(--muted);
    font-size: 13px;
}

.help h2 {
    color: var(--text);
    font-size: 14px;
    margin: 0 0 6px;
}

.help ol { margin: 0; padding-left: 18px; }
.help li { margin: 4px 0; }

/* ------------------------------------------------------------ notatki */

.note {
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}
.note:last-child { border-bottom: 0; }

.note-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 6px;
    flex-wrap: wrap;
    font-size: 13px;
}

.note-author { font-weight: 600; color: var(--text); }
.note-author-boss { color: var(--accent); }

.note-body {
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}

.note-del {
    background: transparent;
    border: 0;
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}
.note-del:hover { color: var(--danger); }

/* ------------------------------------------------------------ pasek instalacji PWA */

.install-bar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px calc(12px + env(safe-area-inset-top));
    background: var(--accent);
    color: var(--accent-t);
    border-bottom: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.install-bar[hidden] { display: none; }

.install-bar-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.install-bar-text strong { font-size: 14px; font-weight: 700; }
.install-bar-text .sub { color: rgba(20, 23, 12, 0.75); font-size: 12px; }

.install-bar-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.install-bar .btn { padding: 8px 12px; }
.install-bar .btn-accent { background: var(--accent-t); color: var(--accent); border-color: var(--accent-t); }
.install-bar .btn-ghost {
    color: var(--accent-t);
    border: 1px solid rgba(20, 23, 12, 0.3);
    background: transparent;
    padding: 4px 10px;
    font-size: 16px;
}

.tag {
    display: inline-block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 7px;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--muted);
    margin-right: 4px;
    margin-top: 4px;
}

.tag-warn { color: var(--warn); border-color: rgba(245, 185, 66, 0.4); }
.tag-ok   { color: var(--ok);   border-color: rgba(86, 214, 138, 0.4); }
.tag-bad  { color: var(--danger); border-color: rgba(255, 107, 107, 0.4); }

.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 18px 0; }

/* ------------------------------------------------------------ formularze */

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

input[type=text], input[type=number], input[type=date], input[type=time],
input[type=password], select, textarea {
    width: 100%;
    padding: 12px 13px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface2);
    color: var(--text);
    font-size: 16px;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    min-height: 46px;
    line-height: 1.2;
}

/* Native date/time picker na iOS wygląda źle jak jest szerszy; zwężamy do naturalnej szerokości. */
input[type=date], input[type=time] {
    max-width: 100%;
    box-sizing: border-box;
    text-align: left;
    font-variant-numeric: tabular-nums;
}

input[type=date]::-webkit-date-and-time-value,
input[type=time]::-webkit-date-and-time-value {
    text-align: left;
}

textarea { resize: vertical; min-height: 76px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.field { margin-bottom: 14px; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

@media (min-width: 520px) {
    .row4 { grid-template-columns: repeat(4, 1fr); }
}

/* ------------------------------------------------------------ modal stop */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(6, 7, 9, 0.82);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 50;
    padding: 0;
}

@media (min-width: 560px) {
    .modal { align-items: center; padding: 20px; }
}

.modal[hidden] { display: none; }

.modal-box {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
    width: 100%;
    max-width: 520px;
    max-height: 92vh;
    overflow-y: auto;
}

@media (min-width: 560px) {
    .modal-box { border-radius: 18px; }
}

/* Fullscreen modal (wpis ręczny) — całe okno na telefonie. */
.modal-full { align-items: stretch; padding: 0; }
.modal-box-full {
    border-radius: 0;
    max-width: none;
    max-height: none;
    min-height: 100vh;
    padding: max(16px, env(safe-area-inset-top)) 18px calc(20px + env(safe-area-inset-bottom));
}
@media (min-width: 560px) {
    .modal-full { align-items: center; padding: 20px; }
    .modal-box-full {
        border-radius: 18px;
        max-width: 560px;
        min-height: 0;
        max-height: 92vh;
    }
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.modal-head h2 { margin: 0; }

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: transparent;
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

/* ------------------------------------------------------------ panel szefa */

.pay {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

@media (min-width: 560px) {
    .pay { grid-template-columns: 1fr 1fr; }
}

.pay-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
}

.pay-row:last-child { border-bottom: 0; }
.pay-row b { font-variant-numeric: tabular-nums; }
.pay-total { font-size: 17px; font-weight: 700; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.month-nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.month-nav select { width: auto; min-width: 150px; }

.scroll-x { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
