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

:root {
    --bg:       #0f1117;
    --surface:  #1a1d27;
    --border:   #2a2d3a;
    --text:     #e2e4ed;
    --muted:    #8b8fa8;
    --accent:   #4f8ef7;
    --ok:       #3ecf73;
    --warn:     #f5a623;
    --crit:     #e5534b;
    --neutral:  #5a5f7a;
    --radius:   8px;
    --font:     'Inter', system-ui, sans-serif;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

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

/* Layout */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 52px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.topbar .logo { font-weight: 700; font-size: 16px; color: var(--text); }
.topbar .logo span { color: var(--accent); }
.topbar nav { margin-left: auto; display: flex; gap: 20px; }
.topbar nav a { color: var(--muted); font-size: 13px; }
.topbar nav a.active, .topbar nav a:hover { color: var(--text); }

.page { max-width: 1280px; margin: 0 auto; padding: 28px 24px; }

/* Stats strip */
.stats-strip {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    flex: 1;
    min-width: 140px;
}
.stat-card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.stat-card .value { font-size: 28px; font-weight: 700; margin-top: 4px; }

/* Table */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}
.card-header .count { color: var(--muted); font-weight: 400; font-size: 13px; }

table { width: 100%; border-collapse: collapse; }
th {
    text-align: left;
    padding: 10px 16px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }

.device-name { font-weight: 500; }
.device-serial { font-size: 11px; color: var(--muted); margin-top: 2px; font-family: monospace; }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .03em;
}
.badge-ok      { background: rgba(62,207,115,.15); color: var(--ok); }
.badge-warn    { background: rgba(245,166,35,.15);  color: var(--warn); }
.badge-crit    { background: rgba(229,83,75,.15);   color: var(--crit); }
.badge-neutral { background: rgba(90,95,122,.2);    color: var(--neutral); }

.dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 5px;
}
.dot-online  { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dot-offline { background: var(--neutral); }

/* Filter bar */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.filter-bar input, .filter-bar select {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    padding: 7px 12px;
    font-size: 13px;
    outline: none;
}
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--accent); }
.filter-bar input { flex: 1; min-width: 200px; }

/* Detail page */
.detail-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    margin-top: 20px;
}
/* Prevent grid children from blowing out the layout */
.detail-grid > * { min-width: 0; }
@media (max-width: 860px) { .detail-grid { grid-template-columns: 1fr; } }

/* Wide tables scroll inside their card instead of pushing the page */
.table-scroll { overflow-x: auto; }
.table-scroll table { min-width: max-content; }

.info-list { list-style: none; }
.info-list li {
    display: flex;
    justify-content: space-between;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.info-list li:last-child { border-bottom: none; }
.info-list .key { color: var(--muted); }
.info-list .val { font-weight: 500; text-align: right; max-width: 60%; word-break: break-all; }

.page-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}
.page-title h1 { font-size: 20px; font-weight: 700; }
.breadcrumb { font-size: 12px; color: var(--muted); margin-bottom: 20px; }
.breadcrumb a { color: var(--muted); }

.empty { padding: 40px; text-align: center; color: var(--muted); }

/* Pagination */
.pagination {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    padding: 14px 16px;
    border-top: 1px solid var(--border);
}
.pagination a, .pagination span {
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 13px;
    border: 1px solid var(--border);
    color: var(--muted);
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Forms */
.field-label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}
.field-label input[type="text"],
.field-label select {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
}
.field-label input[type="text"]:focus,
.field-label select:focus { border-color: var(--accent); }
.checkbox-label { flex-direction: row; align-items: center; color: var(--text);
    font-size: 13px; text-transform: none; letter-spacing: 0; gap: 8px; }

.btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.btn:hover { opacity: .85; }

.btn-small {
    border: 1px solid var(--border);
    background: transparent;
    border-radius: 5px;
    padding: 3px 10px;
    font-size: 12px;
    cursor: pointer;
}
.btn-ok     { border-color: var(--ok);   color: var(--ok); }
.btn-muted  { color: var(--muted); }
.btn-danger { border-color: var(--crit); color: var(--crit); }
.btn-small:hover { opacity: .75; }

/* Remote Control Panel */
.rc-panel {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.rc-card {}
.rc-form { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.rc-row  { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rc-textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    padding: 8px 10px;
    font-size: 13px;
    resize: vertical;
    outline: none;
    font-family: inherit;
}
.rc-textarea:focus { border-color: var(--accent); }
.rc-input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    padding: 8px 10px;
    font-size: 13px;
    font-family: monospace;
    outline: none;
}
.rc-input:focus { border-color: var(--accent); }
.rc-output {
    margin: 0 16px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 12px;
    font-family: monospace;
    color: var(--ok);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
}
.btn-danger-solid {
    background: var(--crit);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.btn-danger-solid:hover { opacity: .85; }

/* Installed apps list */
.app-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0;
    padding: 8px 0;
}
.app-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 20px;
    font-size: 12px;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
}
.app-item:last-child { border-bottom: none; }

/* Alerts */
.alert-ok  {
    background: rgba(62,207,115,.1);
    border: 1px solid rgba(62,207,115,.3);
    color: var(--ok);
    border-radius: var(--radius);
    padding: 10px 16px;
    margin-bottom: 18px;
    font-size: 13px;
}
.alert-err {
    background: rgba(229,83,75,.1);
    border: 1px solid rgba(229,83,75,.3);
    color: var(--crit);
    border-radius: var(--radius);
    padding: 10px 16px;
    margin-bottom: 18px;
    font-size: 13px;
}
