:root {
  --bg: #0f1420;
  --panel: #161d2e;
  --panel-alt: #1d2740;
  --border: #2a3450;
  --text: #e7ebf5;
  --text-dim: #93a0bd;
  --accent: #4f7cff;
  --accent-dim: #2c4494;
  --green: #35c072;
  --red: #e5484d;
  --yellow: #e5b83d;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

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

button, input, select, textarea {
  font-family: inherit;
  font-size: 14px;
}

button {
  cursor: pointer;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-weight: 600;
}
button:hover { background: var(--accent-dim); }
button.secondary { background: var(--panel-alt); color: var(--text); border: 1px solid var(--border); }
button.secondary:hover { background: var(--border); }
button.danger { background: var(--red); }
button.danger:hover { background: #b93337; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, select, textarea {
  background: var(--panel-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); }

label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 4px; }
.field { margin-bottom: 14px; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  flex-shrink: 0;
}
.sidebar .brand { font-size: 20px; font-weight: 800; padding: 0 20px 20px; letter-spacing: -0.5px; }
.sidebar .brand span { color: var(--accent); }
.sidebar nav a {
  display: block;
  padding: 10px 20px;
  color: var(--text-dim);
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { color: var(--text); text-decoration: none; background: var(--panel-alt); }
.sidebar nav a.active { color: var(--text); border-left-color: var(--accent); background: var(--panel-alt); }
.sidebar .user-box { padding: 14px 20px; border-top: 1px solid var(--border); margin-top: 20px; font-size: 13px; color: var(--text-dim); }

.main { flex: 1; padding: 28px 36px; max-width: 1200px; }
.main h1 { margin-top: 0; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.online { background: rgba(53,192,114,0.15); color: var(--green); }
.badge.offline { background: rgba(229,72,77,0.15); color: var(--red); }
.badge.kind { background: var(--panel-alt); color: var(--text-dim); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.thumb {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.thumb .type-icon { font-size: 28px; margin-bottom: 8px; }
.thumb .name { font-weight: 600; margin-bottom: 4px; word-break: break-word; }
.thumb .meta { font-size: 12px; color: var(--text-dim); margin-bottom: 10px; }
.thumb .row-actions { display: flex; gap: 8px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: 420px; max-width: 90vw; max-height: 85vh; overflow: auto; }
.modal h2 { margin-top: 0; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.error-banner { background: rgba(229,72,77,0.15); color: var(--red); border: 1px solid var(--red); border-radius: 6px; padding: 10px 14px; margin-bottom: 16px; }
.empty-state { color: var(--text-dim); padding: 30px 0; text-align: center; }

.auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-box { width: 380px; max-width: 90vw; }
.auth-box .brand { font-size: 26px; font-weight: 800; text-align: center; margin-bottom: 24px; }
.auth-box .brand span { color: var(--accent); }

.day-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.day-picker label { display: flex; align-items: center; gap: 4px; background: var(--panel-alt); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; cursor: pointer; color: var(--text); font-size: 13px; margin-bottom: 0; }
.day-picker input { width: auto; }

.playlist-items { list-style: none; margin: 0; padding: 0; }
.playlist-items li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.playlist-items li:last-child { border-bottom: none; }
.playlist-items .item-name { flex: 1; }
.playlist-items .item-type { color: var(--text-dim); font-size: 12px; width: 70px; }

.device-select-list { max-height: 180px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; padding: 8px; }
.device-select-list label { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; color: var(--text); }
.device-select-list input { width: auto; }

.telemetry-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.telemetry-grid .stat { background: var(--panel-alt); border-radius: 8px; padding: 12px; }
.telemetry-grid .stat .label { font-size: 12px; color: var(--text-dim); }
.telemetry-grid .stat .value { font-size: 18px; font-weight: 700; }

.text-dim { color: var(--text-dim); }
.mt-0 { margin-top: 0; }
.flex-row { display: flex; gap: 10px; align-items: center; }
