:root {
    --bg: #f8fafc;
    --panel: #ffffff;
    --panel-soft: #f8fbff;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #15803d;
    --danger: #b91c1c;
    --border: #dbe3ef;
    --radius: 24px;
    --shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    font-family: Inter, Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

body {
    min-height: 100vh;
}

h1, h2, h3, p {
    margin: 0;
}

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

.hidden {
    display: none !important;
}

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

.center {
    text-align: center;
}

.login-body {
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), transparent 30%),
        radial-gradient(circle at bottom right, rgba(59, 130, 246, 0.12), transparent 30%),
        linear-gradient(180deg, #dbeafe 0%, #eff6ff 100%);
}

.login-shell {
    width: min(100%, 480px);
}

.login-card,
.card {
    background: var(--panel);
    border: 1px solid rgba(219, 227, 239, 0.9);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.login-card {
    padding: 32px;
}

.login-card h1 {
    font-size: 32px;
    margin-bottom: 10px;
}

.login-badge,
.eyebrow {
    display: inline-block;
    color: var(--primary);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
}

.login-form,
.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-form {
    gap: 16px;
    margin-top: 24px;
}

label span,
.field span {
    font-size: 14px;
    font-weight: 700;
    color: #334155;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 13px 14px;
    background: #fff;
    transition: border-color .2s ease, box-shadow .2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(37, 99, 235, 0.85);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

textarea {
    resize: vertical;
    min-height: 96px;
}

.btn {
    border: 0;
    border-radius: 14px;
    padding: 13px 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .14s ease, opacity .2s ease, background .2s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: #e2e8f0;
    color: #0f172a;
}

.btn-block {
    width: 100%;
}

code {
    background: rgba(37, 99, 235, 0.10);
    padding: 2px 8px;
    border-radius: 8px;
}

.alert {
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: 14px;
    line-height: 1.5;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.app-shell {
    max-width: 1600px;
    margin: 0 auto;
    padding: 18px;
}

.narrow-shell {
    max-width: 1200px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 18px;
}

.topbar h1 {
    font-size: 34px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-chip {
    padding: 10px 14px;
    background: rgba(37, 99, 235, 0.08);
    border-radius: 14px;
    color: #1e3a8a;
    font-size: 14px;
}

.toolbar {
    padding: 18px;
    margin-bottom: 18px;
}

.toolbar-grid {
    display: grid;
    grid-template-columns: 1.8fr 220px 180px 180px;
    gap: 14px;
    align-items: end;
}

.stat-box {
    justify-content: center;
    height: 100%;
    background: var(--panel-soft);
    border-radius: 16px;
    padding: 12px 16px;
}

.stat-box strong {
    font-size: 28px;
}

.cardless-stat {
    border: 1px solid var(--border);
}

.summary-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 260px));
    gap: 14px;
    margin: 18px 0;
}

.tab-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.tab-btn {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 12px;
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 700;
}

.tab-btn.active {
    background: rgba(37, 99, 235, 0.10);
    color: #1d4ed8;
    border-color: rgba(37, 99, 235, 0.35);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(340px, 460px) minmax(0, 1fr);
    gap: 18px;
}

.list-panel,
.details-panel,
.history-card,
.security-card {
    padding: 18px;
}

.list-panel {
    min-height: 700px;
}

.panel-header,
.subpanel-header,
.details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.history-panel-header {
    align-items: end;
}

.panel-header h2,
.details-header h2,
.subpanel-header h3 {
    font-size: 22px;
}

.panel-counter {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.installation-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: calc(100vh - 280px);
    overflow: auto;
    padding-right: 4px;
}

.installation-item {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 16px;
    padding: 14px;
    transition: border-color .2s ease, transform .12s ease, box-shadow .2s ease;
}

.installation-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.installation-item.active {
    border-color: rgba(37, 99, 235, 0.5);
    background: rgba(37, 99, 235, 0.06);
}

.installation-select-btn {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
    padding: 0;
}

.installation-item h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
}

.item-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

.mini-link-btn {
    border: 1px solid rgba(37, 99, 235, 0.22);
    background: rgba(37, 99, 235, 0.08);
    color: #1d4ed8;
    border-radius: 10px;
    padding: 8px 12px;
    font-weight: 700;
    cursor: pointer;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 9px;
    border-radius: 999px;
    background: #eef2ff;
    color: #4338ca;
    font-weight: 700;
    font-size: 12px;
}

.details-panel {
    min-height: 700px;
}

.empty-state {
    display: grid;
    place-items: center;
    min-height: 500px;
    text-align: center;
    gap: 12px;
    color: var(--muted);
}

.details-content {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

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

.security-grid-single {
    grid-template-columns: minmax(0, 420px);
    margin-bottom: 14px;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.compact-row {
    justify-content: flex-end;
}

.subpanel {
    background: var(--panel-soft);
    border-radius: 18px;
    padding: 16px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-entry {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
}

.history-entry-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.history-entry p {
    line-height: 1.55;
}

.history-toolbar {
    display: flex;
    gap: 12px;
    align-items: end;
}

.history-search-field {
    min-width: min(100%, 420px);
}

.single-history-search {
    width: min(100%, 420px);
}

.history-subtitle {
    margin-top: 6px;
}

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

.history-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 780px;
}

.history-table th,
.history-table td {
    text-align: left;
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.history-table th {
    background: #f8fafc;
    font-size: 14px;
    color: #334155;
}

.app-alert {
    margin-bottom: 18px;
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    min-width: 260px;
    max-width: 420px;
    padding: 14px 16px;
    border-radius: 16px;
    background: #0f172a;
    color: #fff;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.24);
    z-index: 50;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

@media (max-width: 1100px) {
    .toolbar-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .installation-list {
        max-height: 420px;
    }

    .summary-row {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 760px) {
    .app-shell {
        padding: 12px;
    }

    .topbar,
    .topbar-actions,
    .toolbar-grid,
    .form-grid,
    .security-grid,
    .summary-row,
    .history-toolbar {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    .topbar,
    .topbar-actions,
    .history-toolbar {
        display: flex;
    }

    .topbar h1 {
        font-size: 28px;
    }

    .user-chip {
        width: 100%;
        text-align: center;
    }

    .history-table {
        min-width: 620px;
    }

    .details-header,
    .panel-header,
    .subpanel-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .security-grid-single {
        grid-template-columns: 1fr;
    }

    .compact-row {
        width: 100%;
        justify-content: stretch;
    }
}
