:root {
    --black: #050505;
    --black-soft: #0d0d0e;
    --graphite: #17191c;
    --panel: #202327;
    --panel-soft: #262a2f;
    --line: rgba(255, 255, 255, 0.13);
    --line-strong: rgba(255, 255, 255, 0.24);
    --text: #f4f6f8;
    --muted: #aeb6bf;
    --steel: #7f8790;
    --accent: #41d27d;
    --accent-dark: #167142;
    --warning: #f2b84b;
    --danger: #ef6b6b;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
    --page-bg:
        linear-gradient(135deg, rgba(65, 210, 125, 0.08), transparent 34%),
        linear-gradient(180deg, #050505 0%, #111315 100%);
    --header-bg: rgba(5, 5, 5, 0.84);
    --header-border: rgba(255, 255, 255, 0.08);
    --panel-bg: rgba(23, 25, 28, 0.92);
    --control-bg: rgba(255, 255, 255, 0.06);
    --control-bg-strong: rgba(255, 255, 255, 0.08);
    --field-bg: rgba(255, 255, 255, 0.07);
    --field-focus-bg: rgba(255, 255, 255, 0.1);
    --heading: #ffffff;
    --table-line: rgba(255, 255, 255, 0.08);
    --command-text: #baf3cf;
    --alert-text: #ffe2a5;
    --overlay-bg: rgba(5, 5, 5, 0.78);
    --status-bg: rgba(255, 255, 255, 0.07);
    --status-border: rgba(255, 255, 255, 0.14);
    --status-sent: #dbe8ff;
    --status-process: #ffe0a1;
    --status-done: #baf3cf;
}

:root[data-theme="light"] {
    --black: #eef2f5;
    --black-soft: #ffffff;
    --graphite: #ffffff;
    --panel: #ffffff;
    --panel-soft: #eef3f6;
    --line: rgba(21, 31, 43, 0.14);
    --line-strong: rgba(21, 31, 43, 0.26);
    --text: #15202b;
    --muted: #667483;
    --steel: #7a8794;
    --accent: #159b58;
    --accent-dark: #0d6f3e;
    --warning: #b87613;
    --danger: #c94444;
    --shadow: 0 22px 70px rgba(18, 28, 38, 0.13);
    --page-bg:
        linear-gradient(135deg, rgba(21, 155, 88, 0.09), transparent 36%),
        linear-gradient(180deg, #f7fafc 0%, #edf2f6 100%);
    --header-bg: rgba(255, 255, 255, 0.86);
    --header-border: rgba(21, 31, 43, 0.1);
    --panel-bg: rgba(255, 255, 255, 0.94);
    --control-bg: rgba(21, 31, 43, 0.05);
    --control-bg-strong: rgba(21, 31, 43, 0.07);
    --field-bg: rgba(21, 31, 43, 0.045);
    --field-focus-bg: rgba(255, 255, 255, 0.88);
    --heading: #101820;
    --table-line: rgba(21, 31, 43, 0.09);
    --command-text: #0f7544;
    --alert-text: #6f4800;
    --overlay-bg: rgba(232, 238, 243, 0.82);
    --status-bg: rgba(21, 31, 43, 0.055);
    --status-border: rgba(21, 31, 43, 0.12);
    --status-sent: #31547c;
    --status-process: #8a5d09;
    --status-done: #0f7544;
}

* {
    box-sizing: border-box;
    letter-spacing: 0;
}

html {
    min-height: 100%;
    background: var(--black);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background: var(--page-bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

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

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 76px;
    padding: 0 36px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    backdrop-filter: blur(18px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 190px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.38);
    border-radius: 8px;
    background: linear-gradient(145deg, #f4f4f4, #6d737a 46%, #151515 47%, #34373a);
    color: #050505;
    font-size: 1.22rem;
    font-weight: 900;
}

.brand strong,
.brand small {
    display: block;
}

.brand small,
.panel-label,
.section-title span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.header-state {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
}

.vehicle-chip,
.user-chip,
.text-button,
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--control-bg);
    color: var(--text);
    white-space: nowrap;
}

.user-chip {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.theme-toggle {
    color: var(--text);
}

.theme-toggle span:first-child {
    width: 1.1em;
    text-align: center;
    font-weight: 900;
}

.shell {
    width: min(1180px, calc(100% - 48px));
    margin: 0 auto;
    padding: 44px 0 64px;
}

.setup-alert {
    display: grid;
    gap: 4px;
    margin-bottom: 20px;
    padding: 16px 18px;
    border: 1px solid rgba(242, 184, 75, 0.42);
    border-radius: 8px;
    background: rgba(242, 184, 75, 0.12);
    color: var(--alert-text);
}

.setup-alert code {
    color: var(--text);
}

.workbench {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 18px;
    align-items: start;
}

.form-panel,
.status-panel,
.history-panel,
.pin-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-bg);
    box-shadow: var(--shadow);
}

.form-panel {
    padding: clamp(22px, 4vw, 36px);
}

.section-title {
    margin-bottom: 26px;
}

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

h1 {
    margin-bottom: 0;
    color: var(--heading);
    font-size: clamp(2.2rem, 6vw, 4.5rem);
    line-height: 0.96;
    font-weight: 900;
}

h2 {
    margin-bottom: 14px;
    color: var(--heading);
    font-size: 1.45rem;
    line-height: 1.16;
}

.refuel-form {
    display: grid;
    gap: 18px;
}

.field {
    display: grid;
    gap: 8px;
}

.field span {
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 700;
}

.field input,
.field textarea,
.pin-card input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    outline: none;
    background: var(--field-bg);
    color: var(--text);
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.field input {
    min-height: 58px;
    padding: 14px 16px;
    font-size: 1.35rem;
    font-weight: 800;
}

.field textarea {
    resize: vertical;
    min-height: 118px;
    padding: 14px 16px;
}

.field input:focus,
.field textarea:focus,
.pin-card input:focus {
    border-color: rgba(65, 210, 125, 0.72);
    background: var(--field-focus-bg);
    box-shadow: 0 0 0 4px rgba(65, 210, 125, 0.12);
}

.primary-button,
.secondary-button,
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-weight: 850;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.primary-button {
    width: 100%;
    padding: 13px 20px;
    background: linear-gradient(180deg, var(--accent), #25a961);
    color: #03140b;
}

.secondary-button {
    padding: 12px 18px;
    border-color: var(--line);
    background: var(--control-bg-strong);
    color: var(--text);
}

.icon-button {
    width: 50px;
    padding: 0;
    border-color: var(--line);
    background: var(--control-bg-strong);
    color: var(--text);
    font-size: 1.25rem;
}

.primary-button:hover,
.secondary-button:hover,
.icon-button:hover,
.text-button:hover,
.theme-toggle:hover {
    transform: translateY(-1px);
    border-color: var(--line-strong);
}

.primary-button:disabled,
.secondary-button:disabled,
.icon-button:disabled {
    cursor: wait;
    opacity: 0.62;
    transform: none;
}

.status-panel {
    display: grid;
    gap: 22px;
    padding: 24px;
}

.status-panel strong {
    display: block;
    margin-top: 6px;
    color: var(--heading);
    font-size: 1.25rem;
}

.status-panel p {
    margin-bottom: 0;
    color: var(--muted);
}

.history-section {
    margin-top: 18px;
}

.history-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.history-panel {
    margin-top: 14px;
    overflow: hidden;
}

.history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--line);
}

.history-head h2 {
    margin-bottom: 0;
}

.history-head span {
    color: var(--muted);
}

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

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

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

th {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
}

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

.empty-cell {
    color: var(--steel);
    text-align: center;
}

.amount-cell {
    font-weight: 850;
}

.comment-cell {
    max-width: 360px;
    color: var(--text);
    overflow-wrap: anywhere;
}

.comment-line {
    display: block;
    max-width: 360px;
    margin-top: 4px;
    color: var(--steel);
    font-size: 0.9rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--status-border);
    background: var(--status-bg);
    font-size: 0.9rem;
    font-weight: 800;
}

.status-sent {
    color: var(--status-sent);
}

.status-process {
    color: var(--status-process);
    background: rgba(242, 184, 75, 0.11);
}

.status-done {
    color: var(--status-done);
    background: rgba(65, 210, 125, 0.12);
}

.pin-overlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--overlay-bg);
    backdrop-filter: blur(16px);
}

.pin-overlay[hidden] {
    display: none;
}

.pin-card {
    width: min(420px, 100%);
    padding: 28px;
}

.pin-card input {
    height: 62px;
    margin-bottom: 14px;
    padding: 12px 16px;
    text-align: center;
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: 0.24em;
}

.pin-card p {
    margin: 14px 0 0;
    color: var(--muted);
}

.pin-card .primary-button {
    min-height: 52px;
}

.is-error {
    color: var(--danger) !important;
}

.is-success {
    color: var(--accent) !important;
}

@media (max-width: 860px) {
    .app-header {
        align-items: flex-start;
        flex-direction: column;
        padding: 16px 20px;
    }

    .header-state {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .shell {
        width: min(100% - 28px, 680px);
        padding-top: 22px;
    }

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

}

@media (max-width: 560px) {
    .vehicle-chip,
    .user-chip,
    .text-button,
    .theme-toggle {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    h1 {
        font-size: 2.7rem;
    }

    .history-actions {
        align-items: stretch;
    }

    .secondary-button {
        flex: 1;
    }
}
