:root {
    --bg: #f4f7f8;
    --surface: #ffffff;
    --surface-soft: #eef4f2;
    --line: #dbe5e2;
    --text: #1f2d2d;
    --muted: #687877;
    --primary: #147d73;
    --primary-dark: #0e5e57;
    --accent: #c98421;
    --danger: #b64545;
    --success-soft: #dff3e6;
    --success: #287a42;
    --shadow: 0 10px 28px rgba(26, 47, 45, 0.08);
}

html,
body {
    min-height: 100%;
}

.system-update-page {
    align-items: center;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.system-update-message {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    max-width: 620px;
    padding: 34px;
    text-align: center;
    width: 100%;
}

.system-update-message h1 {
    font-size: 1.55rem;
    margin: 18px 0 10px;
}

.system-update-message p {
    margin-bottom: 8px;
}

.system-update-message small,
.system-update-note {
    color: var(--muted);
}

.system-update-spinner {
    animation: system-update-spin 0.9s linear infinite;
    border: 4px solid #dce8e5;
    border-radius: 50%;
    border-top-color: var(--primary);
    display: inline-block;
    height: 42px;
    width: 42px;
}

@keyframes system-update-spin {
    to {
        transform: rotate(360deg);
    }
}

.update-progress-overlay {
    min-width: min(560px, 82vw);
    text-align: center;
}

.update-progress-overlay strong,
.update-progress-overlay span,
.update-progress-overlay small {
    display: block;
}

.update-progress-overlay strong {
    font-size: 1.2rem;
    margin-bottom: 8px;
}

.update-progress-action {
    font-size: 1rem;
    font-weight: 700;
}

.update-progress-detail,
.update-progress-overlay small {
    color: #d7e3e1;
    font-size: 0.82rem;
    margin-top: 5px;
}

.update-progress-track {
    background: rgba(255, 255, 255, 0.24);
    border-radius: 4px;
    height: 10px;
    margin: 18px 0 7px;
    overflow: hidden;
}

.update-progress-track span {
    background: #54c5b8;
    height: 100%;
    transition: width 0.3s ease;
}

.update-progress-overlay b {
    font-size: 1.25rem;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

a {
    color: var(--primary);
}

a:hover,
a:focus {
    color: var(--primary-dark);
}

.row {
    max-width: 1220px;
}

.app-topbar {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 0 0 8px 8px;
    box-shadow: var(--shadow);
    display: flex;
    margin-bottom: 18px;
    min-height: 58px;
}

.app-brand,
.app-clock {
    color: var(--text);
    display: inline-block;
    font-weight: 700;
    padding: 15px 0;
}

.app-brand {
    font-size: 1.1rem;
}

.app-brand:hover,
.app-clock:hover {
    color: var(--primary);
}

.app-clock {
    line-height: 1.15;
    padding-bottom: 11px;
    padding-top: 11px;
}

.app-clock-time {
    display: block;
    font-size: 1.18rem;
}

.app-clock-date {
    color: var(--muted);
    display: block;
    font-size: 0.78rem;
    font-weight: 650;
    text-transform: capitalize;
}

.sync-status-list {
    align-items: center;
    display: flex;
    gap: 13px;
    min-height: 56px;
    overflow-x: auto;
    padding: 5px 0;
}

.sync-status-item {
    align-items: center;
    color: var(--text);
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 0.72rem;
    gap: 6px;
    line-height: 1.15;
    max-width: 125px;
}

.sync-status-item strong,
.sync-status-item small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sync-status-item strong {
    font-size: 0.75rem;
}

.sync-status-item small {
    color: var(--muted);
    font-size: 0.68rem;
    margin-top: 2px;
}

.sync-status-item .sync-count {
    font-weight: 700;
}

.sync-status-dot {
    background: #8a9897;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(138, 152, 151, 0.14);
    height: 8px;
    width: 8px;
}

.sync-ok .sync-status-dot {
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(40, 122, 66, 0.14);
}

.sync-ok small {
    color: var(--success);
}

.sync-error .sync-status-dot {
    background: var(--danger);
    box-shadow: 0 0 0 3px rgba(182, 69, 69, 0.14);
}

.sync-error small {
    color: var(--danger);
}

.sync-recent .sync-status-dot {
    background: #2f6fb3;
    box-shadow: 0 0 0 3px rgba(47, 111, 179, 0.16);
}

.sync-recent small {
    color: #2f6fb3;
}

.sync-stale .sync-status-dot {
    background: #c79516;
    box-shadow: 0 0 0 3px rgba(199, 149, 22, 0.18);
}

.sync-stale small {
    color: #a97708;
}

.nav-secondary a {
    border-radius: 6px;
    color: var(--muted);
    display: inline-block;
    font-size: 0.88rem;
    padding: 7px 9px;
}

.nav-secondary a:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.app-sidebar {
    padding-left: 0;
    padding-right: 18px;
}

.side-nav {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 8px;
}

.side-nav li {
    margin: 0;
}

.side-nav li a:not(.button) {
    border-radius: 6px;
    color: var(--text);
    font-size: 0.94rem;
    padding: 10px 12px;
}

.side-nav li a:not(.button):hover {
    background: var(--surface-soft);
    color: var(--primary-dark);
}

.app-content {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    min-height: 520px;
    padding: 24px 26px;
}

.app-content > .columns-12,
.app-content > .row {
    margin-left: 0;
    margin-right: 0;
}

h1,
h2,
h3,
h4,
h5 {
    color: var(--text);
    font-weight: 650;
    letter-spacing: 0;
}

p {
    color: var(--text);
}

label {
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 650;
    margin-bottom: 4px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="time"],
input[type="file"],
select,
textarea {
    background-color: #fff;
    border: 1px solid #cad8d5;
    border-radius: 6px;
    box-shadow: none;
    color: var(--text);
    min-height: 38px;
}

input[type="file"] {
    padding: 7px;
}

textarea {
    min-height: 132px;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="time"]:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(20, 125, 115, 0.13);
}

fieldset {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin: 18px 0;
    padding: 16px 18px 18px;
}

legend {
    background: var(--surface);
    color: var(--text);
    font-size: 0.98rem;
    font-weight: 700;
    padding: 0 8px;
}

.button,
button,
input[type="submit"] {
    background: var(--primary);
    border: 0;
    border-radius: 6px;
    box-shadow: 0 6px 16px rgba(20, 125, 115, 0.18);
    color: #fff;
    font-weight: 650;
    min-height: 38px;
    padding: 10px 18px;
}

.button:hover,
button:hover,
input[type="submit"]:hover,
.button:focus,
button:focus,
input[type="submit"]:focus {
    background: var(--primary-dark);
}

.button.secondary,
.secondary.button {
    background: #e9eeee;
    box-shadow: none;
    color: var(--text);
}

.button.secondary:hover,
.secondary.button:hover {
    background: #dce5e3;
}

.button.success,
.success.button {
    background: var(--success);
}

.button.alert,
.alert.button {
    background: var(--danger);
}

table {
    border: 1px solid var(--line);
    border-collapse: separate;
    border-radius: 8px;
    border-spacing: 0;
    overflow: hidden;
    width: 100%;
}

.comparison-table {
    overflow: visible;
}

.comparison-table thead th {
    background: #eef4f2;
    box-shadow: 0 1px 0 var(--line), 0 6px 12px rgba(26, 47, 45, 0.08);
    position: sticky;
    top: 0;
    z-index: 5;
}

.comparison-table thead th:first-child {
    z-index: 6;
}

table thead {
    background: #eef4f2;
}

table thead th {
    color: #213331;
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0;
    padding: 11px 12px;
    text-transform: none;
}

table tr:nth-child(even) {
    background: #fafcfc;
}

table td {
    border-top: 1px solid #edf3f1;
    color: var(--text);
    padding: 10px 12px;
    vertical-align: middle;
    overflow-wrap: anywhere;
    word-break: normal;
}

table a .fas,
table a .fa,
table .fas,
table .fa {
    color: var(--primary);
    font-size: 1rem;
    margin-right: 8px;
}

table th:last-child,
table td:last-child {
    white-space: nowrap;
    width: 1%;
}

table td:last-child a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
}

table td:last-child a:last-child {
    margin-right: 0;
}

table td:last-child .fas,
table td:last-child .fa {
    margin-right: 0;
}

.btn_czysc_baze .fa,
.btn_czysc_baze .fas {
    color: #b42318;
}

.btn_scraper_baze .fa,
.btn_scraper_baze .fas {
    color: #245ea8;
}

.scraper-settings {
    border-top: 1px solid var(--line);
    margin-top: 22px;
    padding-top: 18px;
}

.schedule-settings {
    border-top: 1px solid var(--line);
    margin-top: 22px;
    padding-top: 18px;
}

.schedule-config {
    border-bottom: 1px solid var(--line);
    margin-bottom: 18px;
    padding-bottom: 14px;
}

.schedule-config h4 {
    font-size: 1rem;
    margin-bottom: 12px;
}

.schedule-enabled {
    padding-top: 27px;
}

.schedule-bases {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    margin: 2px 0 14px;
}

.schedule-bases label {
    color: var(--text);
    margin: 0;
}

.schedule-label {
    color: var(--muted);
    flex: 0 0 100%;
    font-size: 0.82rem;
    font-weight: 700;
}

.schedule-last-run {
    color: var(--muted);
    font-size: 0.8rem;
    margin: 0 0 10px;
}

.schedule-last-run .fas {
    color: var(--primary);
    margin-left: 8px;
}

.stats-table {
    table-layout: fixed;
}

.stats-table th,
.stats-table td {
    text-align: center;
    vertical-align: middle;
}

.stats-table th:first-child,
.stats-table td:first-child {
    text-align: left;
    width: 180px;
}

.stats-table th:nth-child(2),
.stats-table td:nth-child(2) {
    width: 110px;
}

.stats-table th:last-child,
.stats-table td:last-child {
    white-space: normal;
    width: auto;
}

.stats-table th:nth-child(n+3),
.stats-table td:nth-child(n+3) {
    border-left: 1px solid #edf3f1;
}

.stats-table .stats-number {
    font-variant-numeric: tabular-nums;
    text-align: center;
}

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

.scraper-config {
    border-bottom: 1px solid var(--line);
    margin-bottom: 18px;
    padding-bottom: 14px;
}

.scraper-config h4 {
    font-size: 1rem;
    margin-bottom: 12px;
}

.scraper-fields::before,
.scraper-fields::after {
    clear: both;
    content: "";
    display: table;
}

.scraper-actions {
    align-items: center;
    clear: both;
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.scraper-actions .button {
    margin-bottom: 0;
}

td input[type="text"],
td input[type="number"],
td select,
td textarea {
    min-width: 220px;
}

textarea {
    width: 100%;
}

textarea[name="wartosc"],
textarea#opis {
    font-family: Consolas, Monaco, "Lucida Console", monospace;
    min-height: 190px;
    min-width: min(100%, 820px);
}

textarea[name*="nazwa"],
input[name*="nazwa"],
input#nazwa {
    min-width: min(100%, 620px);
}

table td:nth-child(3) {
    max-width: 520px;
}

.alert-box {
    border: 0;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}

.alert-box.success {
    background: var(--success-soft);
    color: #1f5e35;
}

.alert-box.alert {
    background: #f7dddd;
    color: #7e2d2d;
}

.alert-box.warning,
.alert-box.secondary {
    background: #fff4dc;
    color: #76521b;
}

.auth-panel,
.security-page {
    max-width: 560px;
}

.auth-panel-wide,
.security-page {
    max-width: 720px;
}

.auth-panel button,
.security-page button {
    margin-top: 8px;
}

.security-details {
    background: #f5f8f7;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.security-details dt {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
    margin-top: 10px;
}

.security-details dt:first-child {
    margin-top: 0;
}

.security-details dd {
    margin: 3px 0 0;
}

.totp-secret,
.provisioning-uri {
    overflow-wrap: anywhere;
}

.totp-qr-wrap {
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    display: flex;
    justify-content: center;
    margin: 16px 0 10px;
    min-height: 254px;
    padding: 16px;
    width: 254px;
}

.totp-qr {
    height: 220px;
    width: 220px;
}

.totp-qr canvas,
.totp-qr img {
    display: block;
    height: 220px;
    max-width: none;
    width: 220px;
}

.totp-manual-note {
    color: var(--muted);
    font-size: 0.88rem;
}

.totp-secret {
    font-size: 1.05rem;
    letter-spacing: 0;
}

.provisioning-uri {
    display: block;
    margin-top: 8px;
    white-space: normal;
}

.security-status,
.recovery-codes {
    background: #f5f8f7;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 22px;
    padding: 18px;
}

.recovery-code-grid {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 16px 0;
}

.recovery-code-grid code {
    text-align: center;
}

.security-reset-option {
    margin: 16px 0;
}

.database-settings {
    border-bottom: 1px solid var(--line);
    margin-bottom: 24px;
    padding-bottom: 20px;
}

.database-settings h3 {
    margin-bottom: 4px;
}

.settings-source {
    color: var(--muted);
    font-size: 0.88rem;
    margin-bottom: 16px;
}

.database-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.database-actions .button {
    margin: 0;
}

@media only screen and (max-width: 40em) {
    .recovery-code-grid {
        grid-template-columns: 1fr;
    }
}

code {
    background: #edf4f2;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: #24403d;
    display: inline-block;
    font-family: Consolas, Monaco, "Lucida Console", monospace;
    padding: 4px 7px;
}

hr {
    border-color: var(--line);
}

.app-footer {
    color: var(--muted);
    font-size: 0.86rem;
    margin-top: 18px;
}

table.mala {
    font-size: 0.5rem;
}

.hidden {
    display: none;
}

.kwota {
    text-align: right;
}

.poz {
    font-size: 0.75rem;
}

.sprzedaz {
    background-color: #dff3e6;
}

.koszt {
    background-color: #fff1c7;
}

@media print {
    body {
        background: #fff;
    }

    a[href]:after {
       display: none;
       visibility: hidden;
    }

    .app-sidebar,
    .app-topbar,
    .app-footer {
        display: none;
    }
}

.search-highlight {
    background-color: #fff0a3;
}

.pagination_digit {
    padding: 0 3px;
}

.bash {
    background-color: #263130;
    border-radius: 8px;
    color: #e9f2ef;
    display: inline-block;
    font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", monospace;
    font-size: small;
    height: 500px;
    overflow-y: scroll;
    padding: 12px;
    width: 100%;
}

.bash pre {
    background: transparent;
    border: 0;
    color: inherit;
    font-family: inherit;
    margin: 0;
    padding: 0;
}

.cena {
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.cena:hover {
    background-color: #eef8f5;
}

.wybrana {
    background-color: #ccefd8 !important;
    box-shadow: inset 4px 0 0 var(--success);
}

@media only screen and (max-width: 64em) {
    .app-topbar {
        display: block;
        margin-left: 0;
        margin-right: 0;
    }

    .sync-status-list {
        min-height: 0;
        padding: 8px 0 12px;
    }

    .app-sidebar {
        padding-right: 0;
    }

    .side-nav {
        margin-bottom: 14px;
    }

    .app-content {
        border-radius: 8px;
        min-height: 0;
        padding: 18px;
    }

    table {
        display: block;
        overflow-x: auto;
    }
}
