:root {
    --bg: #f4f7fb;
    --sidebar: #102a43;
    --sidebar-active: #193b5a;
    --accent: #3fa9f5;
    --primary: #16324f;
    --primary-hover: #214b74;
    --secondary: #e8eef5;
    --secondary-hover: #d8e6f2;
    --text: #172334;
    --muted: #66788a;
    --line: #d8e2ee;
    --header: #e8eef5;
    --white: #ffffff;
    --ok: #2f9e44;
    --due: #f59f00;
    --overdue: #d9480f;
    --locked: #495057;
    --lost: #7b2cbf;
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
    margin: 0;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Arial, sans-serif;
}
a { color: inherit; }

.login-shell {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, #102a43 0%, #183b5c 42%, #f4f7fb 42%);
}
.login-panel {
    width: min(520px, 100%);
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 18px 48px rgba(16, 42, 67, 0.2);
}
.register-panel { width: min(720px, 100%); }
.login-logo {
    width: 190px;
    display: block;
    margin: 0 0 20px;
    background: var(--sidebar);
    border-radius: 6px;
    padding: 12px;
}

.app-shell {
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 230px 1fr;
}
.sidebar {
    background: var(--sidebar);
    color: #dbe7f3;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}
.brand {
    min-height: 110px;
    display: grid;
    place-items: center;
    padding: 18px 18px 10px;
}
.brand img {
    max-width: 190px;
    width: 100%;
    height: auto;
}
.nav {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.nav a {
    text-decoration: none;
    padding: 16px 26px;
    border-left: 4px solid transparent;
    font-size: 1rem;
}
.nav a:hover,
.nav a.active {
    background: var(--sidebar-active);
    border-left-color: var(--accent);
    color: #fff;
}
.sidebar-footer {
    margin-top: auto;
    padding: 16px 20px;
    font-size: 0.85rem;
    color: #b9c9d8;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-footer-links {
    display: grid;
    gap: 6px;
    margin-top: 14px;
}
.sidebar-footer-links a {
    color: #dbe7f3;
    text-decoration: none;
}
.logout-link {
    display: inline-flex;
    margin-top: 14px;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
}

.content {
    min-width: 0;
    padding: 24px 28px;
}
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}
h1 {
    margin: 0;
    color: var(--sidebar);
    font-size: clamp(1.65rem, 1.2rem + 0.8vw, 2.05rem);
    line-height: 1.15;
}
h2 {
    margin: 0 0 10px;
    color: var(--sidebar);
    font-size: 1.08rem;
}
.subtle, .muted {
    color: var(--muted);
    margin: 6px 0 0;
}

.toolbar,
.form-actions,
.equipment-actions-compact {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}
.button,
button,
input[type="submit"] {
    appearance: none;
    border: none;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    min-height: 40px;
    padding: 8px 14px;
    font-weight: 700;
    font-size: 0.92rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.button:hover,
button:hover,
input[type="submit"]:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}
.button.secondary,
button.secondary {
    background: var(--secondary);
    color: var(--sidebar);
    border: 1px solid #d4e0ec;
}
.button.secondary:hover,
button.secondary:hover {
    background: var(--secondary-hover);
    border-color: #a9bed2;
}
button.danger,
.danger {
    background: var(--overdue);
    color: #fff;
}
button:disabled,
.button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.grid { display: grid; gap: 14px; }
.metrics {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    margin-bottom: 22px;
}
.metric {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}
.metric-link {
    color: inherit;
    text-decoration: none;
}
.metric-link:hover {
    border-color: #a9bed2;
    transform: translateY(-1px);
}
.metric-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--sidebar);
}
.metric-label {
    color: var(--muted);
    margin-top: 4px;
}

.panel {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
}
.panel-body { padding: 18px; }
.settings-section { margin: 0 0 20px; }
.section-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.table-wrap {
    overflow-x: auto;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
}
table {
    width: 100%;
    min-width: 920px;
    border-collapse: collapse;
    background: var(--white);
}
th {
    background: var(--header);
    color: var(--sidebar);
    text-align: left;
    font-weight: 800;
    padding: 9px 10px;
    border-right: 1px solid #d2dce8;
    white-space: nowrap;
    font-size: 0.9rem;
}
td {
    padding: 8px 10px;
    border-top: 1px solid #e2e8f0;
    vertical-align: middle;
    font-size: 0.9rem;
}
tr:hover td { background: #f8fbff; }
.table-link {
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
}
.table-link:hover { text-decoration: underline; }

.status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    white-space: nowrap;
}
.status::before {
    content: "";
    width: 11px;
    height: 11px;
    border-radius: 999px;
    background: currentColor;
}
.status.ok { color: var(--ok); }
.status.due { color: var(--due); }
.status.overdue { color: var(--overdue); }
.status.locked { color: var(--locked); }
.status.lost { color: var(--lost); }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}
.score-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.field.full { grid-column: 1 / -1; }
label {
    font-weight: 700;
    color: var(--sidebar);
}
input,
select,
textarea {
    width: 100%;
    min-height: 38px;
    border: 1px solid #c8d4e0;
    border-radius: 5px;
    padding: 7px 9px;
    font: inherit;
    color: var(--text);
    background: var(--white);
}
textarea {
    min-height: 96px;
    resize: vertical;
}
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(63, 169, 245, 0.2);
    border-color: var(--accent);
}
.inline-check {
    width: auto;
    min-height: 0;
    margin-right: 8px;
}
.checklist {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 18px;
    margin-bottom: 14px;
}

.equipment-commandbar {
    display: grid;
    grid-template-columns: minmax(320px, 620px) 160px 105px;
    gap: 12px;
    align-items: center;
    margin: 0 0 18px;
}
.equipment-search { min-height: 40px; }
.equipment-actions-compact {
    justify-content: flex-start;
    align-items: flex-start;
}
.inline-form {
    margin: 0;
    display: inline-flex;
    gap: 10px;
}
.block-form { flex: 1 1 360px; }

.support-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin: 0 0 18px;
    padding: 10px 14px;
    border: 1px solid #f6c56f;
    border-radius: 6px;
    background: #fff4d6;
    color: #5f3e00;
    font-weight: 700;
}
.flash {
    margin: 0 0 18px;
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--white);
    font-weight: 700;
}
.flash.success {
    border-color: #b7dfc1;
    background: #ecf8ef;
    color: #1f6f32;
}
.flash.error {
    border-color: #f1b4a8;
    background: #fff0ed;
    color: #8f2f1b;
}
.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}
.timeline li {
    padding: 0 0 0 12px;
    border-left: 3px solid var(--line);
}
.timeline span {
    display: block;
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 2px;
}
.timeline p { margin: 4px 0 0; }
.mail-original {
    white-space: pre-wrap;
    background: #f8fbff;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px;
    max-height: 320px;
    overflow: auto;
}

@media (max-width: 1080px) {
    .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .score-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { min-height: auto; }
    .brand { min-height: auto; justify-content: start; }
    .brand img { max-width: 150px; }
    .nav { flex-direction: row; flex-wrap: wrap; }
    .nav a { padding: 12px 16px; }
    .sidebar-footer { display: none; }
    .content { padding: 18px; }
    .page-head { display: block; }
    .toolbar { justify-content: flex-start; margin-top: 14px; }
    .metrics, .form-grid, .score-grid, .checklist, .equipment-commandbar { grid-template-columns: 1fr; }
    table { min-width: 760px; }
}
