:root {
    color-scheme: light;
    --bg: #f5f7f9;
    --ink: #16202a;
    --muted: #627386;
    --panel: #ffffff;
    --line: #d9e0e7;
    --accent: #126b63;
    --accent-dark: #0c4d47;
    --danger-bg: #fff0f0;
    --danger: #9e1c1c;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
}

.app-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0;
}

.workspace {
    display: grid;
    gap: 18px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: 38px;
    line-height: 1.05;
}

h2 {
    margin-bottom: 14px;
    font-size: 20px;
}

.status-pill {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 12px;
    background: var(--panel);
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.upload-panel,
.result-card,
.analysis-panel,
.alert {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.upload-panel {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 16px;
}

.file-drop {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    cursor: pointer;
}

.file-drop__icon {
    display: grid;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 8px;
    background: #e8f4f1;
    color: var(--accent);
    font-size: 28px;
    font-weight: 700;
}

.file-drop strong,
.file-drop small {
    display: block;
}

.file-drop small {
    margin-top: 4px;
    color: var(--muted);
    line-height: 1.35;
}

input[type="file"] {
    display: block;
    margin-top: 10px;
    max-width: 100%;
}

button {
    min-height: 44px;
    border: 0;
    border-radius: 7px;
    padding: 0 18px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
}

button:hover {
    background: var(--accent-dark);
}

.table-action {
    min-height: 32px;
    border-radius: 6px;
    padding: 0 10px;
    font-size: 13px;
}

.alert {
    padding: 14px 16px;
}

.alert--error {
    border-color: #f0c5c5;
    background: var(--danger-bg);
    color: var(--danger);
}

.alert--notice {
    background: #fff9e8;
    color: #725312;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.result-card,
.analysis-panel {
    padding: 18px;
}

dl {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 10px 14px;
    margin: 0;
}

dt {
    color: var(--muted);
    font-weight: 700;
}

dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
    white-space: pre-line;
}

.hash,
pre {
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
}

.hints,
.fragments {
    margin: 0;
    padding-left: 20px;
}

.hints li,
.fragments li {
    margin: 8px 0;
}

.activity-summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.activity-summary span {
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 10px;
    background: #f8fafb;
    color: var(--ink);
}

.activity-summary strong {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 12px;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 13px;
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.activity-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.activity-chart {
    display: grid;
    gap: 9px;
}

.time-scale,
.activity-row {
    display: grid;
    grid-template-columns: 132px minmax(260px, 1fr) 84px;
    gap: 12px;
    align-items: center;
}

.time-scale {
    color: var(--muted);
    font-size: 12px;
}

.time-scale__ticks {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
}

.time-scale__ticks span {
    justify-self: center;
}

.time-scale__ticks span:first-child {
    justify-self: start;
}

.time-scale__ticks span:last-child {
    justify-self: end;
}

.activity-row__label strong,
.activity-row__label small {
    display: block;
}

.activity-row__label small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.activity-row__total {
    color: var(--muted);
    font-size: 13px;
    text-align: right;
}

.activity-bar {
    position: relative;
    height: 22px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: repeating-linear-gradient(
        to right,
        #eef2f5 0,
        #eef2f5 1px,
        #ffffff 1px,
        #ffffff 25%
    );
}

.activity-segment {
    position: absolute;
    top: 0;
    bottom: 0;
    min-width: 1px;
}

.activity-segment--jazda,
.activity-dot--jazda {
    background: #1557b0;
}

.activity-segment--praca,
.activity-dot--praca {
    background: #b84f00;
}

.activity-segment--dyspozycyjnosc,
.activity-dot--dyspozycyjnosc {
    background: #8a6b00;
}

.activity-segment--odpoczynek,
.activity-dot--odpoczynek {
    background: #39a66b;
}

pre {
    max-height: 220px;
    margin: 0;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #f8fafb;
    padding: 14px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 10px 8px;
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 13px;
}

.muted {
    color: var(--muted);
}

tr.is-clickable {
    cursor: pointer;
}

tr.is-clickable:hover td {
    background: #f2f7f6;
}

.detail-modal {
    width: min(860px, calc(100% - 32px));
    max-height: min(760px, calc(100% - 32px));
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0;
    color: var(--ink);
    background: var(--panel);
}

.detail-modal::backdrop {
    background: rgba(13, 25, 35, 0.42);
}

.detail-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    padding: 14px 16px;
}

.detail-modal__close {
    width: 34px;
    min-height: 34px;
    padding: 0;
    border-radius: 6px;
}

.detail-modal__body {
    display: grid;
    gap: 14px;
    max-height: calc(100vh - 130px);
    overflow: auto;
    padding: 16px;
}

.detail-modal h3,
.detail-modal h4 {
    margin: 0;
}

.detail-modal h3 {
    font-size: 20px;
}

.detail-modal h4 {
    color: var(--muted);
    font-size: 14px;
}

@media (max-width: 760px) {
    .app-shell {
        width: min(100% - 24px, 1120px);
        padding: 20px 0;
    }

    .page-header,
    .upload-panel {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .page-header {
        display: grid;
    }

    .result-grid {
        grid-template-columns: 1fr;
    }

    dl {
        grid-template-columns: 1fr;
    }

    .activity-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .time-scale,
    .activity-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .time-scale {
        display: none;
    }

    .activity-row__total {
        text-align: left;
    }
}
