:root {
    --bg-main: #f5f7f3;
    --bg-soft: #e9efe4;
    --surface: #ffffff;
    --surface-strong: #0f2a2b;
    --text-main: #1b2a2f;
    --text-soft: #5b6a70;
    --primary: #0d8b7d;
    --primary-dark: #0b6d63;
    --danger: #d14343;
    --warning: #c7771a;
    --border: #d5dfd7;
    --shadow: 0 16px 36px rgba(20, 44, 42, 0.12);
    --radius-lg: 20px;
    --radius-md: 14px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande", sans-serif;
    color: var(--text-main);
}

/* Auth pages */
.auth-page {
    background:
        radial-gradient(circle at 12% 12%, rgba(13, 139, 125, 0.2), transparent 46%),
        radial-gradient(circle at 86% 18%, rgba(122, 181, 145, 0.24), transparent 40%),
        linear-gradient(135deg, #f7faf5 0%, #eef5ee 50%, #e6f0ea 100%);
}

.auth-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    padding: 32px;
    gap: 20px;
    animation: fade-up 0.7s ease;
}

.auth-panel {
    border-radius: var(--radius-lg);
}

.auth-panel-info {
    background: linear-gradient(160deg, #103b39 0%, #14514b 70%, #2b6c5f 100%);
    color: #f4fcf8;
    padding: 42px;
    box-shadow: var(--shadow);
}

.eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.74rem;
    color: rgba(244, 252, 248, 0.72);
}

.auth-panel-info h1 {
    margin: 12px 0 14px;
    font-size: clamp(1.9rem, 3vw, 2.6rem);
    line-height: 1.1;
}

.auth-copy {
    margin: 0;
    max-width: 42ch;
    color: rgba(244, 252, 248, 0.9);
    line-height: 1.6;
}

.auth-features {
    margin: 30px 0 0;
    padding-left: 20px;
    display: grid;
    gap: 10px;
    color: rgba(244, 252, 248, 0.95);
}

.auth-panel-form {
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    width: min(480px, 100%);
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 34px;
}

.auth-card h2 {
    margin: 0 0 8px;
    font-size: 1.8rem;
}

.subtitle {
    margin: 0 0 22px;
    color: var(--text-soft);
}

.auth-form {
    display: grid;
    gap: 8px;
}

label {
    font-size: 0.9rem;
    font-weight: 700;
}

input,
select {
    width: 100%;
    border: 1px solid var(--border);
    background: #fefefe;
    border-radius: 12px;
    padding: 12px 13px;
    font: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea {
    width: 100%;
    border: 1px solid var(--border);
    background: #fefefe;
    border-radius: 12px;
    padding: 12px 13px;
    font: inherit;
    resize: vertical;
    min-height: 92px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 139, 125, 0.18);
}

.btn {
    border: 0;
    border-radius: 12px;
    background: linear-gradient(140deg, var(--primary) 0%, #1c9b8d 100%);
    color: #fff;
    font-weight: 700;
    font-size: 0.98rem;
    padding: 12px 16px;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
}

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

.error {
    margin-bottom: 14px;
    border: 1px solid rgba(209, 67, 67, 0.25);
    background: rgba(209, 67, 67, 0.08);
    color: #9f2d2d;
    border-radius: 10px;
    padding: 10px 12px;
}

.auth-switch {
    margin: 18px 0 0;
    color: var(--text-soft);
}

.auth-switch a {
    color: var(--primary-dark);
    font-weight: 700;
    text-decoration: none;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* Dashboard */
.dashboard-page {
    background:
        radial-gradient(circle at 90% 0%, rgba(13, 139, 125, 0.2), transparent 26%),
        linear-gradient(180deg, #f3f8f5 0%, #edf4ef 100%);
}

.dashboard-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px 1fr;
}

.sidebar {
    background: var(--surface-strong);
    color: #ebf5f4;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 24px;
}

.brand-block h2 {
    margin: 8px 0 0;
    font-size: 1.5rem;
}

.nav-group {
    margin-top: 22px;
}

.nav-title {
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.72rem;
    color: rgba(235, 245, 244, 0.7);
}

.sidebar ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 6px;
}

.sidebar a {
    color: #e6f2f1;
    text-decoration: none;
    display: block;
    border-radius: 10px;
    padding: 10px 12px;
    transition: background 0.2s ease;
}

.sidebar a:hover,
.sidebar a.active {
    background: rgba(255, 255, 255, 0.14);
}

.logout-btn {
    background: linear-gradient(145deg, #d14343 0%, #b93737 100%);
    text-align: center;
}

.main-content {
    padding: 28px;
    display: grid;
    gap: 22px;
    align-content: start;
    animation: fade-up 0.6s ease;
}

.dashboard-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.dashboard-header h1 {
    margin: 0;
    font-size: clamp(1.5rem, 2.3vw, 2.1rem);
}

.dashboard-header p {
    margin: 6px 0 0;
    color: var(--text-soft);
}

.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 14px;
    white-space: nowrap;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #11a36f;
}

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

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    padding: 18px;
    box-shadow: 0 8px 18px rgba(16, 41, 39, 0.06);
}

.stat-card p {
    margin: 0;
    color: var(--text-soft);
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 2rem;
    line-height: 1;
}

.delta {
    display: inline-block;
    margin-top: 8px;
    font-size: 0.86rem;
    font-weight: 700;
}

.delta.positive {
    color: #1f8256;
}

.delta.warning {
    color: var(--warning);
}

.delta.critical {
    color: var(--danger);
}

.content-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 14px;
}

.panel {
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    padding: 16px;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
}

.panel-head h3 {
    margin: 0;
}

.panel-head a {
    color: var(--primary-dark);
    font-weight: 700;
    text-decoration: none;
}

.panel-head a:hover {
    text-decoration: underline;
}

.panel-btn {
    width: auto;
    padding: 10px 14px;
}

.panel-subtitle {
    margin: 8px 0 14px;
    color: var(--text-soft);
}

.devices-search-form {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}

.devices-search-form input {
    max-width: 340px;
}

.devices-search-form select {
    max-width: 220px;
}

.search-reset {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

.checks-grid label {
    font-weight: 600;
    font-size: 0.86rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.checks-grid input[type="checkbox"] {
    width: auto;
    margin: 0;
    flex: 0 0 auto;
    transform: translateY(1px);
}

.detail-btn {
    text-decoration: none;
}

.metric-bars {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    height: 180px;
    margin-top: 14px;
}

.metric-col {
    width: 32px;
    display: grid;
    justify-items: center;
    gap: 6px;
}

.metric-col i {
    width: 100%;
    border-radius: 8px 8px 2px 2px;
    background: linear-gradient(180deg, var(--primary), var(--primary-dark));
}

.metric-col small {
    color: var(--text-soft);
    font-weight: 700;
}

.notice {
    border-radius: 10px;
    padding: 10px 12px;
    margin: 0 0 12px;
    font-weight: 700;
}

.notice.success {
    border: 1px solid rgba(19, 130, 84, 0.28);
    background: rgba(19, 130, 84, 0.1);
    color: #1a6a49;
}

.notice.error-notice {
    border: 1px solid rgba(209, 67, 67, 0.3);
    background: rgba(209, 67, 67, 0.1);
    color: #8f2e2e;
}

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

.credentials-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 620px;
}

.credentials-table th,
.credentials-table td {
    text-align: left;
    padding: 11px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.credentials-table th {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-soft);
}

.table-sort {
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    text-transform: inherit;
    letter-spacing: inherit;
    cursor: pointer;
    padding: 0;
}

.table-sort:hover {
    color: var(--primary-dark);
}

.type-badge {
    display: inline-flex;
    align-items: center;
    border: 1px solid rgba(13, 139, 125, 0.25);
    background: rgba(13, 139, 125, 0.1);
    color: var(--primary-dark);
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 0.78rem;
    font-weight: 700;
}

.type-badge.status-crit {
    border-color: rgba(209, 67, 67, 0.35);
    background: rgba(209, 67, 67, 0.14);
    color: #a13131;
}

.type-badge.status-offline {
    border-color: rgba(128, 141, 146, 0.4);
    background: rgba(128, 141, 146, 0.18);
    color: #58656a;
}

.type-badge.status-warn {
    border-color: rgba(199, 119, 26, 0.35);
    background: rgba(199, 119, 26, 0.12);
    color: #8a5312;
}

.type-badge.status-online,
.type-badge.status-ok {
    border-color: rgba(19, 130, 84, 0.35);
    background: rgba(19, 130, 84, 0.12);
    color: #1f8256;
}

.type-badge.status-unknown {
    border-color: rgba(93, 108, 117, 0.4);
    background: rgba(93, 108, 117, 0.18);
    color: #415159;
}

.empty-row {
    color: var(--text-soft);
}

.row-actions {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.edit-btn {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: rgba(20, 99, 176, 0.14);
    color: #24568f;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
}

.edit-btn:hover {
    background: rgba(20, 99, 176, 0.24);
}

.trash-btn {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: rgba(209, 67, 67, 0.12);
    color: #b32f2f;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
}

.trash-btn:hover {
    background: rgba(209, 67, 67, 0.2);
}

.assign-btn {
    border: 0;
    border-radius: 10px;
    background: rgba(13, 139, 125, 0.14);
    color: var(--primary-dark);
    height: 34px;
    padding: 0 10px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}

.assign-btn:hover {
    background: rgba(13, 139, 125, 0.22);
}

.event-list {
    list-style: none;
    padding: 0;
    margin: 14px 0 0;
    display: grid;
    gap: 10px;
}

.event-list li {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "name time"
        "desc time";
    gap: 2px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
}

.event-list span {
    grid-area: name;
    font-weight: 700;
}

.event-list small {
    grid-area: desc;
    color: var(--text-soft);
}

.event-list time {
    grid-area: time;
    color: var(--text-soft);
    font-size: 0.82rem;
}

.system-bars {
    margin-top: 14px;
    display: grid;
    gap: 12px;
}

.compact-bars {
    margin-top: 8px;
    gap: 8px;
}

.bar-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
}

.bar-row span,
.bar-row small {
    color: var(--text-soft);
    font-weight: 700;
}

.bar {
    height: 10px;
    background: #d8e6df;
    border-radius: 999px;
    overflow: hidden;
}

.compact-bars .bar {
    height: 8px;
}

.status-lists-grid {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.status-list-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
}

.status-list-card h4 {
    margin: 0 0 6px;
}

.compact-list {
    margin-top: 0;
    gap: 6px;
}

.compact-list li {
    padding: 8px;
}

.bar i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary-dark), var(--primary));
}

.bar-row.row-online .bar i {
    background: linear-gradient(90deg, #177247, #1f9d5c);
}

.bar-row.row-warn .bar i {
    background: linear-gradient(90deg, #a85f11, #d78525);
}

.bar-row.row-crit .bar i {
    background: linear-gradient(90deg, #a13131, #d14343);
}

.bar-row.row-offline .bar i {
    background: linear-gradient(90deg, #5a666c, #7b8b92);
}

.bar-row.row-unknown .bar i {
    background: linear-gradient(90deg, #4c5960, #687780);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(8, 23, 23, 0.54);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: min(460px, 100%);
    padding: 22px;
    box-shadow: var(--shadow);
    animation: zoom-in 0.2s ease;
}

.modal-content h2 {
    margin: 0 0 16px;
}

.modal-form {
    display: grid;
    gap: 8px;
}

.close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: #edf3ef;
    color: #3e5251;
    font-size: 1.4rem;
    cursor: pointer;
}

.close:hover {
    background: #dce9e2;
}

@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes zoom-in {
    from {
        opacity: 0;
        transform: scale(0.97);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@media (max-width: 1060px) {
    .auth-layout {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .status-lists-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .dashboard-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        padding: 16px;
    }

    .main-content {
        padding: 16px;
    }

    .dashboard-header {
        flex-direction: column;
    }

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

    .auth-layout {
        padding: 14px;
    }

    .auth-panel-info,
    .auth-card {
        padding: 24px;
    }

    .devices-search-form {
        flex-direction: column;
        align-items: stretch;
    }

    .devices-search-form input {
        max-width: none;
    }
}
