* {
    box-sizing: border-box;
}

:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --accent: #0f766e;
    --accent-strong: #115e59;
    --danger: #b91c1c;
    --warning: #d97706;
    --border: #e5e7eb;
}

body {
    margin: 0;
    font-family: "IBM Plex Sans", "Segoe UI", Tahoma, sans-serif;
    color: var(--text);
    background: var(--bg);
}

a {
    color: var(--accent);
    text-decoration: none;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 28px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}

.topbar h1 {
    margin: 0 0 4px 0;
    font-size: 20px;
}

.topbar-left {
    display: flex;
    flex-direction: column;
}

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

.muted {
    color: var(--muted);
    font-size: 13px;
}

.content {
    padding: 24px 28px 40px;
}

.summary {
    padding: 20px 28px 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.summary-cards {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.summary-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
}

.summary-label {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}

.summary-value {
    font-size: 20px;
    font-weight: 700;
}

.summary-value-good {
    color: #15803d;
}

.summary-value-bad {
    color: #b91c1c;
}

.summary-value-warn {
    color: #b45309;
}

.summary-value-small {
    font-size: 14px;
    font-weight: 600;
}

.summary-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.summary-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
}

.summary-panel h3 {
    margin: 0 0 10px;
    font-size: 14px;
}

.summary-panel-danger {
    border-color: #fecaca;
    background: #fff7f7;
}

.summary-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.summary-list li {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.summary-list-danger .summary-item-title {
    color: var(--danger);
}

.summary-item-title {
    font-weight: 600;
    font-size: 13px;
}

.summary-item-meta {
    color: var(--muted);
    font-size: 12px;
}

.summary-empty {
    color: var(--muted);
    font-size: 13px;
}

.filters {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    padding: 20px 28px 0;
}

.filter-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 28px 0;
    flex-wrap: wrap;
}

.filter-actions-left,
.filter-actions-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-group label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: 14px;
    background: #fff;
}

.status-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

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

.status-table th:first-child,
.status-table td:first-child {
    width: 36px;
}

.status-table input[type="checkbox"] {
    margin: 0;
}

.status-table th {
    background: #f9fafb;
    color: var(--muted);
    font-weight: 600;
}

.farm-header td {
    background: #eef2f7;
    font-weight: 600;
}

.farm-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.farm-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.farm-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.farm-group.is-collapsed tr.site-row {
    display: none;
}

.row-disabled {
    opacity: 0.6;
}

.title-cell {
    display: flex;
    gap: 8px;
    align-items: center;
}

.meta {
    margin-left: 8px;
    color: var(--muted);
    font-size: 12px;
}

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.status-up {
    background: #dcfce7;
    color: #166534;
}

.status-down {
    background: #fee2e2;
    color: #991b1b;
}

.status-paused {
    background: #fef3c7;
    color: #92400e;
}

.status-unknown {
    background: #e5e7eb;
    color: #374151;
}

.badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 6px;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-muted {
    background: #e5e7eb;
    color: #374151;
}

.status-light {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    display: inline-block;
    box-shadow: 0 0 0 2px #fff, 0 0 6px rgba(15, 23, 42, 0.15);
}

.status-light-green {
    background: #22c55e;
}

.status-light-yellow {
    background: #f59e0b;
}

.status-light-red {
    background: #ef4444;
}

.btn-collapse {
    border: 1px solid var(--border);
    color: var(--muted);
    background: #fff;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
}

.btn-collapse:hover {
    color: var(--text);
    border-color: #cbd5e1;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 13px;
    cursor: pointer;
}

.btn-small {
    padding: 5px 8px;
    font-size: 12px;
}

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

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

.btn-secondary {
    border: 1px solid var(--border);
    color: var(--text);
    background: #fff;
}

.btn-link {
    background: transparent;
    border: none;
    color: var(--accent);
    padding: 5px 6px;
}

.btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.status-table tbody tr.site-row:hover td {
    background: #f8fafc;
}

.card {
    background: var(--card);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.detail-label {
    color: var(--muted);
    font-size: 12px;
}

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
}

.form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-row {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 12px;
    color: var(--muted);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-actions {
    display: flex;
    gap: 10px;
}

.form-hint {
    font-size: 12px;
    color: var(--muted);
    margin-top: -6px;
}

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #e2e8f0 0%, #fef3c7 100%);
    padding: 24px;
}

.auth-card {
    background: #fff;
    padding: 32px;
    border-radius: 16px;
    border: 1px solid var(--border);
    width: min(420px, 100%);
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.15);
}

.auth-card h1 {
    margin-top: 0;
}

.empty-state {
    text-align: center;
    padding: 40px;
    background: var(--card);
    border-radius: 12px;
    border: 1px dashed var(--border);
}

@media (max-width: 900px) {
    .status-table {
        border-collapse: separate;
        border-spacing: 0 12px;
        background: transparent;
        box-shadow: none;
    }

    .status-table thead {
        display: none;
    }

    .status-table,
    .status-table tbody,
    .status-table tr,
    .status-table td {
        display: block;
        width: 100%;
    }

    .status-table td:first-child {
        width: 100%;
    }

    .status-table tbody.farm-group {
        margin-bottom: 18px;
    }

    .status-table tr.farm-header {
        margin: 0 0 12px;
    }

    .status-table tr.farm-header td {
        border-radius: 12px;
        border: 1px solid var(--border);
    }

    .status-table tr.farm-header td::before {
        content: none;
    }

    .status-table tr.site-row {
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: 12px;
        margin: 12px 0;
        overflow: hidden;
        box-shadow: 0 10px 25px rgba(15, 23, 42, 0.06);
    }

    .status-table tr.site-row td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        border-bottom: 1px solid var(--border);
    }

    .status-table tr.site-row td:last-child {
        border-bottom: none;
    }

    .status-table tr.site-row td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--muted);
        min-width: 110px;
    }

    .status-table tr.site-row td .title-cell {
        flex-direction: column;
        align-items: flex-start;
    }

    .status-table tr.site-row td .meta {
        margin-left: 0;
    }

    .status-table tr.site-row td .actions {
        width: 100%;
        justify-content: flex-start;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .topbar-actions {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
    }
}
