:root {
    --navy: #072e5f;
    --navy-2: #0b447f;
    --blue: #087ef5;
    --blue-soft: #eaf4ff;
    --teal: #07cbb5;
    --green: #0f9f70;
    --red: #d13a4c;
    --amber: #c87908;
    --ink: #14233b;
    --muted: #65748b;
    --line: #dde5ef;
    --surface: #ffffff;
    --canvas: #f5f8fc;
    --shadow: 0 18px 48px rgba(17, 47, 84, .10);
}

* { box-sizing: border-box; }
html { font-family: "Segoe UI", Tahoma, Arial, sans-serif; color: var(--ink); background: var(--canvas); }
body { margin: 0; min-height: 100vh; }
button, input { font: inherit; }
a { color: inherit; }

.login-page {
    display: grid;
    place-items: center;
    padding: 28px;
    background:
        radial-gradient(circle at 12% 10%, rgba(8, 126, 245, .13), transparent 32%),
        radial-gradient(circle at 88% 90%, rgba(7, 203, 181, .12), transparent 30%),
        var(--canvas);
}

.login-card {
    width: min(460px, 100%);
    padding: 34px;
    border: 1px solid rgba(221, 229, 239, .9);
    border-radius: 28px;
    background: rgba(255, 255, 255, .96);
    box-shadow: var(--shadow);
}

.login-logo { display: block; width: 230px; max-height: 142px; object-fit: contain; margin: 0 auto 18px; }
.eyebrow { color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 7px 0 8px; color: var(--navy); font-size: clamp(27px, 4vw, 38px); line-height: 1.15; }
h2 { margin: 0; color: var(--navy); font-size: 19px; }
.muted, .panel-head p { color: var(--muted); }
.login-card .muted { margin: 0 0 24px; line-height: 1.6; }
label { display: grid; gap: 8px; margin: 16px 0; color: #40506a; font-size: 13px; font-weight: 700; }
input {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid #cfd9e7;
    border-radius: 11px;
    background: #fff;
    color: var(--ink);
    outline: none;
}
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(8, 126, 245, .12); }
input[readonly] { background: #f2f5f9; color: #66758c; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 11px;
    text-decoration: none;
    font-weight: 750;
    cursor: pointer;
}
.button-primary { background: linear-gradient(135deg, var(--blue), #096bd3); color: #fff; box-shadow: 0 8px 20px rgba(8, 126, 245, .22); }
.button-secondary { border-color: #c9d7e8; background: #fff; color: var(--navy); }
.button-block { width: 100%; margin-top: 9px; }
.security-note { margin: 20px 0 0; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.5; }

.alert { margin: 16px 0; padding: 13px 15px; border-radius: 12px; font-size: 14px; }
.alert-danger { border: 1px solid #f2c6cc; background: #fff1f3; color: #9c2333; }
.alert-success { border: 1px solid #b8ead9; background: #eefbf7; color: #087452; }
.alert-code { display: flex; align-items: center; justify-content: space-between; gap: 20px; border: 1px solid #b9d9fb; background: var(--blue-soft); }
.alert-code span { color: var(--muted); font-size: 12px; }
.alert-code code { padding: 10px 14px; border-radius: 9px; background: var(--navy); color: #fff; font-size: 16px; letter-spacing: .08em; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 68px;
    padding: 8px max(24px, calc((100vw - 1240px) / 2));
    border-bottom: 1px solid rgba(221, 229, 239, .9);
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 15px; color: var(--navy); font-weight: 800; }
.brand img { width: 105px; height: 50px; object-fit: contain; }
.brand span { padding-left: 15px; border-left: 1px solid var(--line); }
.top-actions { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 4px rgba(7, 203, 181, .13); }
.text-link { margin-left: 18px; color: var(--navy); font-weight: 700; text-decoration: none; }

.container { width: min(1240px, calc(100% - 36px)); margin: 0 auto; padding: 38px 0 70px; }
.hero-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 25px; margin-bottom: 28px; }
.hero-row p { margin: 8px 0 0; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-actions form { margin: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.stat-card, .panel { border: 1px solid var(--line); background: var(--surface); box-shadow: 0 6px 24px rgba(18, 52, 92, .05); }
.stat-card { display: grid; gap: 6px; min-height: 132px; padding: 20px; border-radius: 17px; }
.stat-card span { color: var(--muted); font-size: 13px; font-weight: 650; }
.stat-card strong { color: var(--navy); font-size: 30px; line-height: 1; }
.stat-card small { color: #8290a4; }

.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.panel { padding: 22px; border-radius: 18px; margin-bottom: 18px; }
.panel-grid .panel { margin-bottom: 0; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.panel-head p { margin: 5px 0 0; font-size: 13px; }
.pill { flex: 0 0 auto; padding: 6px 10px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-size: 12px; font-weight: 800; }
.pill-green { background: #e8faf4; color: var(--green); }
.progress { height: 12px; overflow: hidden; border-radius: 99px; background: #e8eef6; }
.progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--teal)); }
.storage-labels { display: flex; justify-content: space-between; margin: 9px 0 17px; color: var(--muted); font-size: 12px; }
.inline-form { display: flex; align-items: flex-end; gap: 11px; margin-top: 18px; }
.inline-form label { flex: 1; margin: 0; }
.inline-form input { max-width: 190px; }
.schedule-list { display: grid; gap: 1px; overflow: hidden; margin: 6px 0 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--line); }
.schedule-list div { display: flex; justify-content: space-between; padding: 11px 13px; background: #fff; font-size: 13px; }
.schedule-list span { color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; text-align: left; text-transform: uppercase; letter-spacing: .05em; }
td { padding: 15px 10px; border-bottom: 1px solid #edf1f6; color: #34445d; font-size: 13px; vertical-align: middle; }
td small { display: block; max-width: 150px; margin-top: 4px; overflow: hidden; color: #8996a9; text-overflow: ellipsis; }
tr:last-child td { border-bottom: 0; }
.empty { padding: 38px 15px; color: var(--muted); text-align: center; }
.device-status { display: inline-block; padding: 5px 8px; border-radius: 8px; font-size: 11px; font-weight: 800; }
.status-active { background: #e8faf4; color: var(--green); }
.status-paused { background: #fff6e7; color: var(--amber); }
.status-suspended, .status-revoked { background: #fff0f2; color: var(--red); }
.status-auto_approved, .status-confirmed { background: #fff6e7; color: var(--amber); }
.status-restored { background: #e8faf4; color: var(--green); }
.action-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 0; }
.mini-button { padding: 6px 9px; border: 1px solid #cad6e5; border-radius: 8px; background: #fff; color: var(--navy); font-size: 11px; font-weight: 750; cursor: pointer; }
.mini-button.warning { border-color: #efd3a8; color: #9c5b00; }
.mini-button.danger { border-color: #efc2c8; color: var(--red); }
.empty-block { padding: 32px 10px; border: 1px dashed #ced9e7; border-radius: 12px; color: var(--muted); text-align: center; }
.event-list, .incident-list { display: grid; gap: 9px; }
.event { display: flex; gap: 11px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid #edf1f6; }
.event:last-child { border-bottom: 0; }
.event-icon { flex: 0 0 auto; width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }
.event strong, .event small { display: block; }
.event strong { font-size: 13px; }
.event small { margin-top: 4px; color: #8a97a9; font-size: 11px; }
.incident { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px; border: 1px solid #f1c6cc; border-radius: 12px; background: #fff7f8; }
.incident strong, .incident span { display: block; }
.incident span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.recovery-stats { grid-template-columns: repeat(4, 1fr); }
.recovery-list { display: grid; gap: 12px; }
.recovery-item { display: grid; grid-template-columns: 240px 1fr auto; align-items: center; gap: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; }
.recovery-meta { display: grid; justify-items: start; gap: 5px; }
.recovery-meta span:not(.device-status), .recovery-meta small { color: var(--muted); font-size: 11px; }
.recovery-paths { display: grid; gap: 4px; min-width: 0; }
.recovery-paths code { overflow: hidden; color: #40516a; font-family: "Segoe UI", sans-serif; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.recovery-paths span { color: var(--muted); font-size: 11px; }

@media (max-width: 940px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .panel-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .container { width: min(100% - 22px, 1240px); padding-top: 25px; }
    .topbar { padding: 7px 12px; }
    .brand span, .top-actions > span:not(.status-dot) { display: none; }
    .hero-row { align-items: stretch; flex-direction: column; }
    .hero-actions, .hero-actions a, .hero-actions form, .hero-actions button { width: 100%; }
    .stat-grid { grid-template-columns: 1fr; }
    .panel { padding: 16px; }
    .inline-form, .alert-code, .incident { align-items: stretch; flex-direction: column; }
    .recovery-item { grid-template-columns: 1fr; }
}
