:root {
    --bg:           #f0f2f5;
    --surface:      #ffffff;
    --surface2:     #f7f8fa;
    --border:       #e2e6ea;
    --text:         #1a1d23;
    --text-muted:   #6b7280;
    --accent:       #3b82f6;
    --accent-hover: #2563eb;
    --online:       #22c55e;
    --offline:      #ef4444;
    --unknown:      #d1d5db;
    --shadow:       0 2px 8px rgba(0,0,0,0.08);
    --shadow-hover: 0 6px 20px rgba(0,0,0,0.13);
    --radius:       12px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:           #0f1117;
        --surface:      #1a1d27;
        --surface2:     #22263a;
        --border:       #2d3148;
        --text:         #e8eaf0;
        --text-muted:   #8b90a8;
        --accent:       #4f8ef7;
        --accent-hover: #6ba3ff;
        --online:       #4ade80;
        --offline:      #f87171;
        --unknown:      #4b5563;
        --shadow:       0 2px 8px rgba(0,0,0,0.4);
        --shadow-hover: 0 6px 20px rgba(0,0,0,0.5);
    }
}

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

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

/* ── Banner ── */
.banner {
    width: 100%;
    padding: .75rem 2rem;
    font-size: .9rem;
}
.banner-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: flex-start;
    gap: .75rem;
}
.banner-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.banner-body { display: flex; flex-direction: column; gap: .2rem; }
.banner-body strong { font-weight: 700; }

.banner-green  { background: #dcfce7; color: #166534; border-bottom: 2px solid #86efac; }
.banner-yellow { background: #fef9c3; color: #854d0e; border-bottom: 2px solid #fde047; }
.banner-orange { background: #ffedd5; color: #9a3412; border-bottom: 2px solid #fdba74; }
.banner-red    { background: #fee2e2; color: #991b1b; border-bottom: 2px solid #fca5a5; }

@media (prefers-color-scheme: dark) {
    .banner-green  { background: #14290f; color: #86efac; border-color: #166534; }
    .banner-yellow { background: #2d2200; color: #fde047; border-color: #854d0e; }
    .banner-orange { background: #2d1500; color: #fdba74; border-color: #9a3412; }
    .banner-red    { background: #2d0f0f; color: #fca5a5; border-color: #991b1b; }
}

/* ── Header ── */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
header h1 { font-size: 1.25rem; font-weight: 700; }

.admin-btn {
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    padding: .4rem 1rem;
    border-radius: 8px;
    font-size: .875rem;
    font-weight: 600;
    transition: background .15s;
}
.admin-btn:hover { background: var(--accent-hover); }

/* ── Main grid ── */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}
.empty { text-align: center; color: var(--text-muted); margin-top: 4rem; font-size: 1.1rem; }
.empty a { color: var(--accent); text-decoration: none; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

/* ── Card ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    transition: box-shadow .18s, transform .18s, border-color .18s;
    position: relative;
}
.card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); border-color: var(--accent); }

.card-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    background: var(--surface2);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; overflow: hidden;
}
.card-icon img { width: 28px; height: 28px; object-fit: contain; }
.icon-fallback {
    font-size: 1.3rem; font-weight: 700; color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%; text-transform: uppercase;
}

.card-body { flex: 1; min-width: 0; }
.card-name { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-url  { font-size: .78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

/* Card notice badge */
.card-notice {
    display: inline-block;
    margin-top: .45rem;
    padding: .15rem .5rem;
    border-radius: 6px;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.notice-green  { background: #dcfce7; color: #166534; }
.notice-yellow { background: #fef9c3; color: #854d0e; }
.notice-orange { background: #ffedd5; color: #9a3412; }
.notice-red    { background: #fee2e2; color: #991b1b; }

@media (prefers-color-scheme: dark) {
    .notice-green  { background: #14290f; color: #86efac; }
    .notice-yellow { background: #2d2200; color: #fde047; }
    .notice-orange { background: #2d1500; color: #fdba74; }
    .notice-red    { background: #2d0f0f; color: #fca5a5; }
}

.status-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--unknown);
    flex-shrink: 0;
    margin-top: 4px;
    transition: background .3s;
}
.status-dot.online  { background: var(--online); }
.status-dot.offline { background: var(--offline); }

/* ── Admin shared ── */
.admin-wrap { max-width: 960px; margin: 2rem auto; padding: 0 1.5rem; }

.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .5rem 1.1rem;
    border-radius: 8px; font-size: .875rem; font-weight: 600;
    border: none; cursor: pointer; text-decoration: none;
    transition: background .15s;
}
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover   { background: var(--accent-hover); }
.btn-danger    { background: #ef4444; color: #fff; }
.btn-danger:hover    { background: #dc2626; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }

.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}
.form-card h3 { margin-bottom: 1.25rem; font-size: 1.05rem; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: .82rem; font-weight: 600; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
    padding: .55rem .8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface2);
    color: var(--text);
    font-size: .9rem;
    font-family: inherit;
    transition: border-color .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--accent);
}
.form-group textarea { resize: vertical; min-height: 70px; }
.form-actions { margin-top: 1.25rem; display: flex; gap: .75rem; align-items: center; }

/* Color picker row */
.color-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.color-opt { display: none; }
.color-opt + label {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .3rem .75rem; border-radius: 20px; font-size: .8rem; font-weight: 600;
    cursor: pointer; border: 2px solid transparent; transition: border-color .15s;
}
.color-opt:checked + label { border-color: var(--text); }
.color-opt[value="green"]  + label { background: #dcfce7; color: #166534; }
.color-opt[value="yellow"] + label { background: #fef9c3; color: #854d0e; }
.color-opt[value="orange"] + label { background: #ffedd5; color: #9a3412; }
.color-opt[value="red"]    + label { background: #fee2e2; color: #991b1b; }

/* Services table */
.services-table { width: 100%; border-collapse: collapse; }
.services-table th {
    background: var(--surface2); padding: .75rem 1rem; text-align: left;
    font-size: .78rem; text-transform: uppercase; letter-spacing: .5px;
    color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.services-table td { padding: .8rem 1rem; border-bottom: 1px solid var(--border); font-size: .88rem; vertical-align: middle; }
.services-table tr:last-child td { border-bottom: none; }
.services-table tr:hover td { background: var(--surface2); }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 380px; box-shadow: var(--shadow);
}
.login-card h2 { margin-bottom: 1.5rem; text-align: center; }

.alert { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .875rem; }
.alert-error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
@media (prefers-color-scheme: dark) {
    .alert-error   { background: #3b1515; color: #fca5a5; border-color: #7f1d1d; }
    .alert-success { background: #14290f; color: #86efac; border-color: #166534; }
}

.icon-preview { width: 32px; height: 32px; object-fit: contain; border-radius: 6px; vertical-align: middle; }

details summary { cursor: pointer; font-weight: 600; padding: .5rem 0; color: var(--text-muted); user-select: none; }
details summary:hover { color: var(--text); }

.toggle-row { display: flex; align-items: center; gap: .75rem; }
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0; background: var(--border); border-radius: 24px; cursor: pointer; transition: .2s;
}
.toggle-slider:before {
    content: ''; position: absolute; width: 18px; height: 18px; left: 3px; bottom: 3px;
    background: white; border-radius: 50%; transition: .2s;
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider:before { transform: translateX(20px); }
