:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-hover: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-dim: #64748b;
    --green: #10b981;
    --green-bg: rgba(16, 185, 129, 0.08);
    --green-border: rgba(16, 185, 129, 0.25);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.07);
    --red-border: rgba(239, 68, 68, 0.25);
    --yellow: #f59e0b;
    --yellow-bg: rgba(245, 158, 11, 0.07);
    --yellow-border: rgba(245, 158, 11, 0.25);
    --blue: #3b82f6;
    --blue-bg: rgba(59, 130, 246, 0.07);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────────── */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-logo {
    height: 55px;
    width: auto;
    flex-shrink: 0;
    display: block;
}

#access-denied {
    min-height: calc(100vh - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.access-denied-inner {
    max-width: 400px;
    width: 100%;
    border-left: 3px solid var(--red);
    padding: 2rem 2rem 2rem 1.75rem;
    background: var(--surface);
    border-radius: 0 var(--radius) var(--radius) 0;
    box-shadow: var(--shadow);
}

.access-denied-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--red);
    margin-bottom: 0.6rem;
}

.access-denied-inner h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
    margin-bottom: 0.6rem;
}

.access-denied-inner p {
    font-size: 0.82rem;
    color: var(--text-dim);
    line-height: 1.6;
    margin-bottom: 1.25rem;
}

.access-denied-user {
    font-size: 0.78rem;
    color: var(--text-dim);
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border-radius: 6px;
    margin-bottom: 1rem;
}

.access-denied-user strong {
    color: var(--text);
}

.access-denied-inner button {
    font-size: 0.8rem;
    color: var(--text-dim);
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.9rem;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.access-denied-inner button:hover {
    color: var(--red);
    border-color: var(--red-border);
}

.subtitle {
    color: var(--text-dim);
    font-size: 0.82rem;
    font-weight: 400;
}

.header-meta {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-dim);
    font-size: 0.78rem;
}

.refresh-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    display: inline-block;
    flex-shrink: 0;
}

.refresh-dot.polling {
    animation: pulse 0.6s ease-in-out;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.3; transform: scale(1.6); }
}

/* ── User menu ────────────────────────────────────────────── */
.user-menu {
    position: relative;
    margin-left: 0.25rem;
}

.user-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.32rem 0.7rem;
    color: var(--text-dim);
    font-size: 0.78rem;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.user-btn:hover {
    border-color: var(--border-strong);
    color: var(--text);
    background: var(--surface);
}

.user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.5rem;
    box-shadow: var(--shadow-md);
    z-index: 200;
}

.user-dropdown.open { display: block; }

.user-dropdown-info {
    font-size: 0.78rem;
    color: var(--text-dim);
    padding: 0.4rem 0.6rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-dropdown-role {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 0.2rem 0.6rem;
    margin: 0.2rem 0.4rem 0;
    border-radius: 4px;
    display: inline-block;
}

.user-dropdown-role.role-super {
    background: rgba(139, 92, 246, 0.08);
    color: #7c3aed;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.user-dropdown-role.role-org {
    background: var(--blue-bg);
    color: var(--blue);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.user-dropdown-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0.4rem 0;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.6rem;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text-dim);
    font-size: 0.82rem;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
}

.user-dropdown-item:hover {
    background: var(--bg);
    color: var(--text);
}

.logout-btn:hover { color: var(--red) !important; }

/* ── Main layout ──────────────────────────────────────────── */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.75rem 2rem;
}

/* ── Overall banner ───────────────────────────────────────── */
.banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.4rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.banner-ok      { background: var(--green-bg);  border-color: var(--green-border); }
.banner-fail    { background: var(--red-bg);    border-color: var(--red-border); }
.banner-degraded{ background: var(--yellow-bg); border-color: var(--yellow-border); }
.banner-unknown { background: var(--surface); }

.banner-icon { display: flex; align-items: center; flex-shrink: 0; }
.banner-text h2 { font-size: 1rem; font-weight: 600; color: var(--text); }
.banner-text p  { font-size: 0.82rem; color: var(--text-dim); margin-top: 0.2rem; }

/* ── Sections ─────────────────────────────────────────────── */
.card-section { margin-bottom: 2rem; }

.section-title {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    margin-bottom: 0.65rem;
}

/* ── Card grid ────────────────────────────────────────────── */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.75rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    box-shadow: var(--shadow);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}

.card-wide { grid-column: span 1; }

.card-indicator {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-top: 0.35rem;
    flex-shrink: 0;
    background: var(--border);
}

.card-indicator.ok   { background: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
.card-indicator.fail { background: var(--red);   box-shadow: 0 0 0 3px var(--red-bg); }
.card-indicator.warn { background: var(--yellow);box-shadow: 0 0 0 3px var(--yellow-bg); }

.card-body    { flex: 1; min-width: 0; }
.card-title   { font-size: 0.75rem; color: var(--text-dim); font-weight: 500; }
.card-subtitle{ font-size: 0.7rem; color: var(--text-dim); opacity: 0.7; margin-top: 0.1rem; font-family: monospace; }
.card-value   { font-size: 1.05rem; font-weight: 600; margin-top: 0.2rem; color: var(--text); }
.card-value-lg{ font-size: 1.45rem; }
.card-detail  { font-size: 0.72rem; color: var(--text-dim); margin-top: 0.15rem; }

/* ── Server metric rows ───────────────────────────────────── */
.card-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 1rem;
    margin-top: 0.5rem;
}

.metric { display: flex; justify-content: space-between; align-items: baseline; }
.metric-label { font-size: 0.72rem; color: var(--text-dim); }
.metric-value {
    font-size: 0.88rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}
.metric-value.warn { color: var(--yellow); }
.metric-value.crit { color: var(--red); }

/* ── Footer ───────────────────────────────────────────────── */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-dim);
    font-size: 0.72rem;
    border-top: 1px solid var(--border);
}

/* ── SIM cards ────────────────────────────────────────────── */
.sim-count {
    font-weight: 400;
    color: var(--text-dim);
    font-size: 0.72rem;
    text-transform: none;
    letter-spacing: 0;
}

.sim-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: var(--shadow);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.sim-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}

.sim-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.sim-name {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

.sim-badge {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    flex-shrink: 0;
}

.sim-badge.online  { background: var(--green-bg);  color: var(--green); border: 1px solid var(--green-border); }
.sim-badge.offline { background: var(--red-bg);    color: var(--red);   border: 1px solid var(--red-border); }

.sim-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem 1rem;
    font-size: 0.75rem;
}

.sim-meta-label { color: var(--text-dim); }
.sim-meta-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }

.sim-usage-section { margin-top: 0.25rem; }

.sim-usage-label {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-bottom: 0.3rem;
    display: flex;
    justify-content: space-between;
}

.sim-usage-bar-bg {
    height: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.sim-usage-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.sim-usage-bar-fill.low    { background: var(--green); }
.sim-usage-bar-fill.medium { background: var(--yellow); }
.sim-usage-bar-fill.high   { background: var(--red); }

.sim-network {
    font-size: 0.7rem;
    color: var(--text-dim);
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.sim-network span {
    background: var(--blue-bg);
    color: var(--blue);
    border: 1px solid rgba(59, 130, 246, 0.2);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    header { padding: 0.75rem 1rem; }
    main   { padding: 1rem; }
    .card-grid    { grid-template-columns: 1fr 1fr; }
    .card-metrics { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .card-grid { grid-template-columns: 1fr; }
}
