:root {
    --bg:        #f0f2f5;
    --surface:   #ffffff;
    --surface2:  #f8f9fb;
    --border:    #e2e5eb;
    --text:      #111827;
    --muted:     #6b7280;
    --accent:    #2563eb;
    --accent-h:  #1d4ed8;
    --accent-bg: #eff6ff;
    --danger:    #dc2626;
    --danger-bg: #fef2f2;
    --success:   #16a34a;
    --success-bg:#f0fdf4;
    --warn:      #d97706;
    --warn-bg:   #fffbeb;
    --radius:    12px;
    --radius-sm: 8px;
    --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,.1);
    --sidebar-w: 240px;
}
.theme-dark {
    --bg:        #0d1117;
    --surface:   #161b22;
    --surface2:  #1c2128;
    --border:    #30363d;
    --text:      #e6edf3;
    --muted:     #8b949e;
    --accent-bg: #1f3a6e;
    --danger-bg: #3d1515;
    --success-bg:#122712;
    --warn-bg:   #3d2b0a;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-tap-highlight-color: transparent; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg); color: var(--text); min-height: 100vh; font-size: 15px; line-height: 1.5;
}
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .65rem 1.2rem; border-radius: var(--radius-sm); border: none;
    font-size: .9rem; font-weight: 600; cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-ghost   { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--border); }
.btn-sm      { padding: .35rem .7rem; font-size: .8rem; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block   { width: 100%; }
label { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: .35rem; }
input[type="email"], input[type="password"], input[type="text"] {
    width: 100%; padding: .7rem .9rem; border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: 1rem; transition: border-color .15s;
}
input:focus { outline: none; border-color: var(--accent); }
.err-msg { color: var(--danger); font-size: .85rem; margin-top: .5rem; text-align: center; min-height: 1.2rem; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2.5rem 2rem; width: 100%; max-width: 400px; box-shadow: var(--shadow-md); }
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo img { height: 32px; display: block; margin: 0 auto .75rem; }
.login-badge { display: inline-block; background: var(--accent); color: #fff; font-size: .65rem; font-weight: 700; padding: .15rem .5rem; border-radius: 4px; letter-spacing: .5px; text-transform: uppercase; margin-bottom: .5rem; }
.login-subtitle { color: var(--muted); font-size: .85rem; }
.login-field { margin-bottom: 1rem; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; overflow-y: auto;
}
.sidebar-brand { padding: 1.25rem 1.25rem 1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .75rem; }
.sidebar-brand img { height: 26px; }
.sidebar-badge { background: var(--accent); color: #fff; font-size: .6rem; font-weight: 700; padding: .12rem .4rem; border-radius: 4px; letter-spacing: .5px; text-transform: uppercase; }
.nav-section { padding: .75rem .75rem 0; }
.nav-section-label { font-size: .68rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; padding: 0 .5rem .5rem; }
.nav-item {
    display: flex; align-items: center; gap: .65rem; padding: .6rem .75rem;
    border-radius: var(--radius-sm); cursor: pointer; font-size: .88rem;
    color: var(--muted); transition: all .15s; border: none; background: none; width: 100%; text-align: left; margin-bottom: .1rem;
}
.nav-item:hover  { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.nav-icon { font-size: .95rem; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-footer { padding: .75rem; border-top: 1px solid var(--border); margin-top: auto; display: flex; flex-direction: column; gap: .4rem; }
.theme-btn { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: none; color: var(--muted); font-size: .82rem; cursor: pointer; width: 100%; }
.theme-btn:hover { background: var(--bg); }
.main-wrap { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }
.topbar { height: 60px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 1.5rem; position: sticky; top: 0; z-index: 50; gap: 1rem; }
.topbar-title { font-size: 1.05rem; font-weight: 700; }
.topbar-actions { margin-left: auto; }
.main { padding: 1.5rem; }

/* Mobile nav */
.mobile-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); z-index: 100; padding: .3rem 0 calc(.3rem + env(safe-area-inset-bottom)); }
.mobile-nav-inner { display: flex; justify-content: space-around; }
.mobile-nav-btn { display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .4rem .5rem; border-radius: var(--radius-sm); border: none; background: none; color: var(--muted); font-size: .62rem; font-weight: 600; cursor: pointer; min-width: 52px; }
.mobile-nav-btn.active { color: var(--accent); }
.mobile-nav-btn .nav-icon { font-size: 1.25rem; width: auto; }

/* Cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; box-shadow: var(--shadow); }
.card-icon  { font-size: 1.4rem; margin-bottom: .5rem; }
.card-label { font-size: .7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: .4rem; }
.card-value { font-size: 1.8rem; font-weight: 800; line-height: 1; letter-spacing: -.5px; }
.card-sub   { font-size: .78rem; color: var(--muted); margin-top: .3rem; }
.progress-bar  { height: 5px; background: var(--border); border-radius: 3px; margin-top: .6rem; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; background: var(--accent); transition: width .4s; }
.progress-fill.warn   { background: var(--warn); }
.progress-fill.danger { background: var(--danger); }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: .18rem .6rem; border-radius: 99px; font-size: .72rem; font-weight: 700; }
.badge-ok    { background: var(--success-bg); color: var(--success); }
.badge-err   { background: var(--danger-bg);  color: var(--danger); }
.badge-warn  { background: var(--warn-bg);    color: var(--warn); }
.badge-muted { background: var(--surface2);   color: var(--muted); }

/* Section title */
.section-title { font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin: 1.5rem 0 .75rem; }
.section-title:first-child { margin-top: 0; }

/* Services */
.service-list { display: flex; flex-direction: column; gap: .75rem; }
.service-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; box-shadow: var(--shadow); }
.service-info { flex: 1; min-width: 140px; }
.service-name { font-weight: 700; font-size: .95rem; }
.service-unit { font-size: .75rem; color: var(--muted); margin-top: .1rem; font-family: monospace; }
.service-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Log */
.log-box { background: #0d1117; color: #c9d1d9; font-family: "SF Mono", Consolas, monospace; font-size: .75rem; padding: 1rem; border-radius: var(--radius); height: 260px; overflow-y: auto; white-space: pre-wrap; word-break: break-all; border: 1px solid var(--border); line-height: 1.65; }

/* IP cards */
.ip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.ip-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow); }
.ip-label { font-size: .7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: .25rem; }
.ip-value { font-family: monospace; font-size: .9rem; word-break: break-all; }
.dns-result { font-family: monospace; font-size: .85rem; margin-top: .75rem; padding: .6rem .9rem; border-radius: var(--radius-sm); background: var(--surface2); border: 1px solid var(--border); }

/* Responsive */
@media (max-width: 768px) {
    .sidebar    { display: none; }
    .main-wrap  { margin-left: 0; padding-bottom: calc(65px + env(safe-area-inset-bottom)); }
    .mobile-nav { display: block; }
    .main       { padding: 1rem; }
    .topbar     { padding: 0 1rem; }
    .card-grid  { grid-template-columns: 1fr 1fr; gap: .75rem; }
    .card-value { font-size: 1.5rem; }
    .card       { padding: 1rem; }
    .service-row { padding: .85rem 1rem; }
    .ip-grid    { grid-template-columns: 1fr; }
}
