* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f4f6f8;
    color: #1f2933;
    line-height: 1.5;
}

a {
    color: #2563eb;
    text-decoration: none;
}

header {
    background: #111827;
    color: #fff;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header nav a {
    color: #e5e7eb;
    margin-left: 16px;
}

main {
    max-width: 1280px;
    margin: 24px auto;
    padding: 0 16px 40px;
}

.card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.card h2, .card h3 {
    margin-top: 0;
}

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

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    border-bottom: 1px solid #e5e7eb;
    padding: 8px 10px;
    text-align: left;
    vertical-align: top;
}

th {
    background: #f9fafb;
}

.status-running {
    color: #047857;
    font-weight: 600;
}

.status-stopped {
    color: #b91c1c;
    font-weight: 600;
}

.flash {
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.flash-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

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

.flash-info {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 100%;
    max-width: 420px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

input, select, textarea {
    width: 100%;
    padding: 8px 10px;
    margin-bottom: 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
}

button, .btn {
    display: inline-block;
    background: #2563eb;
    color: #fff;
    border: 0;
    border-radius: 6px;
    padding: 8px 14px;
    cursor: pointer;
}

button.secondary, .btn.secondary {
    background: #6b7280;
}

button.danger, .btn.danger {
    background: #dc2626;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

pre.status-text {
    white-space: pre-wrap;
    background: #111827;
    color: #e5e7eb;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
}

.inline-form {
    display: inline;
}

.small {
    font-size: 0.9rem;
    color: #6b7280;
}

.error-box {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.bandwidth-table {
    width: 100%;
    max-width: 640px;
    border-collapse: collapse;
    margin-top: 4px;
}

.bandwidth-table th,
.bandwidth-table td {
    border: 1px solid #e5e7eb;
    padding: 12px 16px;
    text-align: center;
}

.bandwidth-table th {
    background: #f3f4f6;
    font-weight: 700;
    color: #374151;
}

.bandwidth-table th:first-child,
.bandwidth-table td.bandwidth-row-label {
    text-align: left;
    background: #f9fafb;
    font-weight: 600;
    color: #4b5563;
    width: 28%;
}

.bandwidth-table td.bandwidth-value {
    font-size: 1.05rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.bandwidth-table th.th-rx,
.bandwidth-table td.td-rx {
    color: #2563eb;
}

.bandwidth-table th.th-tx,
.bandwidth-table td.td-tx {
    color: #dc2626;
}

.bandwidth-table tbody tr:hover td {
    background: #f8fafc;
}

.bandwidth-table tbody tr:hover td.bandwidth-row-label {
    background: #f3f4f6;
}

.chart-card h3 {
    margin-bottom: 8px;
    color: #374151;
    font-size: 0.95rem;
}

.section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.section-heading h2 {
    margin: 0;
}

.chart-row {
    display: grid;
    gap: 16px;
}

.chart-row-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.chart-panel {
    min-width: 0;
}

.chart-container {
    position: relative;
    height: 240px;
    margin-bottom: 4px;
}

@media (max-width: 960px) {
    .chart-row-3,
    .chart-row-2 {
        grid-template-columns: 1fr;
    }

    .chart-container {
        height: 260px;
    }
}

.chart-message {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 16px;
    text-align: center;
    color: #b45309;
    font-weight: 600;
    background: rgba(255, 251, 235, 0.96);
    border: 1px dashed #f59e0b;
    border-radius: 6px;
    z-index: 2;
}

.chart-message.is-visible {
    display: flex;
}

.traffic-hint {
    margin: 12px 0 0;
}

.trend-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    margin: 0;
    cursor: pointer;
    white-space: nowrap;
    color: #6b7280;
}

.trend-toggle input {
    width: auto;
    margin: 0;
}

.traffic-usage-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

.traffic-usage-table .col-period {
    width: 12%;
}

.traffic-usage-table .col-metric {
    width: 14.66%;
}

.traffic-usage-table th,
.traffic-usage-table td {
    text-align: center;
    font-variant-numeric: tabular-nums;
    padding: 10px 8px;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: middle;
}

.traffic-usage-table thead th {
    background: #f9fafb;
    font-weight: 700;
}

.traffic-usage-table .th-period,
.traffic-usage-table .td-period {
    text-align: left;
    font-weight: 600;
    color: #4b5563;
}

.traffic-usage-table .th-group {
    text-align: center;
    letter-spacing: 0.02em;
}

.traffic-usage-table .th-group-biz {
    background: #eff6ff;
    color: #1e3a8a;
    border-bottom: 2px solid #93c5fd;
}

.traffic-usage-table .th-group-backup {
    background: #fff7ed;
    color: #9a3412;
    border-bottom: 2px solid #fdba74;
    border-left: 3px solid #fb923c;
}

.traffic-usage-table .th-rx,
.traffic-usage-table .td-rx {
    color: #2563eb;
    font-weight: 700;
    text-align: center;
}

.traffic-usage-table .th-tx,
.traffic-usage-table .td-tx {
    color: #dc2626;
    font-weight: 700;
    text-align: center;
}

.traffic-usage-table .th-total,
.traffic-usage-table .td-total {
    color: #111827;
    font-weight: 700;
    text-align: center;
}

.traffic-usage-table .th-backup,
.traffic-usage-table .td-backup {
    background: #fffaf5;
}

.traffic-usage-table .th-group-backup,
.traffic-usage-table .th-backup-start,
.traffic-usage-table .td-backup-start {
    border-left: 3px solid #fb923c;
}

.traffic-usage-table tbody tr:hover td {
    background: #f8fafc;
}

.traffic-usage-table tbody tr:hover td.td-backup {
    background: #fff3e6;
}

.warning-message {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    color: #92400e;
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 12px;
}
