:root {
  --ink: #16212b;
  --ink-soft: #223040;
  --bg: #f5f3ee;
  --panel: #ffffff;
  --line: #e3dfd5;
  --muted: #75726a;
  --amber: #d98a2b;
  --amber-soft: #fbead3;
  --teal: #2f6f5e;
  --teal-soft: #e6f0ec;
  --danger: #c1492f;
  --danger-soft: #fbe7e1;
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, Menlo, monospace;
  --sans: "Inter", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body.app-body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.5;
  height: 100%;
}
/* ---------- App shell: sidebar + main ---------- */
/*.app-shell { display: flex; min-height: 100vh; }*/
.app-shell { display: flex; height: 100vh; }

/*.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--ink);
  color: #e7e6e2;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
}*/

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: #800080;
  color: #e7e6e2;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 50;
}

/*.brand { display: flex; align-items: center; gap: 8px; padding: 0 6px 22px; }
.brand-mark { color: var(--amber); font-size: 20px; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: 0.02em; }
*/
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 14px; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: 0.02em; color: #fff; }

.nav-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8b9099;
  padding: 6px 10px 4px;
}
/*.nav-group { display: flex; flex-direction: column; gap: 2px; flex: 1; }*/
.nav-group { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  color: #c7cad0;
  text-decoration: none;
  font-size: 14px;
}
.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-link.active { background: var(--amber); color: #1a1305; font-weight: 600; }
.nav-icon { font-size: 13px; opacity: 0.001; width: 0; } /* icon glyphs omitted, text-only nav kept compact */

.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.1); padding-top: 10px; margin-top: auto; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 0 6px 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--amber); color: #1a1305;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.user-chip-name { font-size: 13px; font-weight: 600; color: #fff; }
.user-chip-role { font-size: 11px; color: #9ba0a8; text-transform: capitalize; }
.logout-link { display: block; padding: 6px 6px 0; font-size: 13px; color: #c7cad0; text-decoration: none; }
.logout-link:hover { color: var(--amber); }

/*.main-area { flex: 1; min-width: 0; }
.main-area { flex: 1; min-width: 0; margin-left: 230px; }*/

.main-area { flex: 1; min-width: 0; margin-left: 230px; display: flex; flex-direction: column; min-height: 100vh; overflow-y: auto; }

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 18px 28px;
}
.topbar h1 { font-size: 19px; margin: 0; letter-spacing: 0.01em; }
.content { padding: 24px 28px 40px; max-width: 1180px; flex: 1; }
/* ---------- Generic building blocks ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-header h2 { font-size: 15px; margin: 0; }
.panel-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 880px) { .grid-2 { grid-template-columns: 1fr; } }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); border-bottom: 1px solid var(--line); padding: 8px 10px;
}
table.data-table td { padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data-table tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
}
.badge-admin { background: var(--amber-soft); color: #8a560f; }
.badge-user { background: var(--teal-soft); color: var(--teal); }
.badge-online { background: var(--teal-soft); color: var(--teal); }
.badge-offline { background: #efece4; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--ink); color: #fff; border: none;
  padding: 8px 16px; font-size: 13.5px; border-radius: 7px; cursor: pointer;
  text-decoration: none; font-family: var(--sans);
}
.btn:hover { background: var(--ink-soft); }
.btn-primary { background: var(--amber); color: #1a1305; font-weight: 600; }
.btn-primary:hover { background: #c47b1f; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a23a25; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-sm { padding: 5px 5px; font-size: 12.5px; border-radius: 6px; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }


a.btn-ghost,
a.btn-ghost:link,
a.btn-ghost:visited,
a.btn-ghost:hover,
a.btn-ghost:active,
a.btn-ghost:focus,
a.btn-ghost:focus-visible {
  background: transparent !important;
  outline: none !important;
  box-shadow: none !important;
  color: var(--ink) !important;
}


button.btn-ghost:active,
button.btn-ghost:focus,
button.btn-ghost:hover,
button.btn-ghost:focus-visible {
  background: transparent !important;
  outline: none !important;
  box-shadow: none !important;
  color: var(--ink) !important;
}

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.04em; }
.form-row input, .form-row select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px;
  font-size: 14px; font-family: var(--sans); background: #fdfcfa;
}
.form-row input:focus, .form-row select:focus { outline: 2px solid var(--amber); border-color: var(--amber); }
.form-inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }

.alert { padding: 10px 14px; border-radius: 7px; font-size: 13.5px; margin-bottom: 16px; }
.alert-success { background: var(--teal-soft); color: var(--teal); }
.alert-error { background: var(--danger-soft); color: var(--danger); }

.empty-state {
  text-align: center; padding: 40px 16px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 10px; background: #fbfaf7;
}

/* ---------- Device cards (user dashboard) ---------- */
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.device-card-link { text-decoration: none; color: inherit; }
.device-tile {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px; transition: border-color 0.15s, transform 0.15s;
}
.device-tile:hover { border-color: var(--amber); transform: translateY(-2px); }
.device-tile-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.device-tile-id { font-family: var(--mono); font-weight: 700; font-size: 15px; }
.device-tile-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.device-tile-playlist { font-size: 13px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }

/* ---------- File / playlist manager (device.php) ---------- */
.file-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 8px; border-bottom: 1px solid var(--line);
}
.file-row:last-child { border-bottom: none; }
.file-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--amber); }
.file-wave { color: var(--amber); font-family: var(--mono); font-size: 13px; }
.file-name { flex: 1; font-size: 13.5px; }
.file-meta { font-size: 11.5px; color: var(--muted); font-family: var(--mono); }

.playlist-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 8px; border-bottom: 1px solid var(--line);
  background: #fff; cursor: grab;
}
.playlist-row:last-child { border-bottom: none; }
.playlist-row.dragging { opacity: 0.4; }
.playlist-index {
  width: 22px; height: 22px; border-radius: 50%; background: var(--teal-soft); color: var(--teal);
  display: flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 700; flex-shrink: 0;
}
.playlist-name { flex: 1; font-size: 13.5px; }
.drag-handle { color: var(--muted); font-family: var(--mono); cursor: grab; padding: 0 4px; }


.upload-dropzone {
  display: block;
  border: 2px dashed var(--line);
  border-radius: 8px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  margin-bottom: 14px;
  background: var(--bg);
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
}
.upload-dropzone:hover {
  border-color: var(--amber);
  background: var(--amber-soft);
}
.upload-dropzone input[type="file"] {
  display: none;
}


.toast {
  position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 8px; font-size: 13.5px; opacity: 0; transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s; pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------- Logs (reuses card pattern) ---------- */
.device-logcard { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 16px; overflow: hidden; }
.device-logcard-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--teal-soft); font-family: var(--mono); font-weight: 700;
}
.log-line { font-family: var(--mono); font-size: 13px; padding: 9px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; }
.log-line:last-child { border-bottom: none; }
.log-line .time { color: var(--muted); min-width: 150px; }
.log-line .file { flex: 1; }
.status-success { color: var(--teal); }
.status-fail { color: var(--danger); }

/* ---------- Auth page ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--ink); }
.auth-card { background: #fff; border-radius: 12px; padding: 36px 32px; width: 360px; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand .brand-mark { color: var(--amber); font-size: 26px; }
.auth-brand h2 { margin: 6px 0 0; font-size: 17px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(22,33,43,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-box {
  background: var(--panel);
  border-radius: 12px;
  padding: 28px 32px;
  width: 100%; max-width: 480px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h3 { margin: 0; font-size: 17px; }
.modal-close {
  color: var(--muted); text-decoration: none; font-size: 18px;
  line-height: 1; padding: 2px 6px; border-radius: 4px;
}
.modal-close:hover { background: var(--line); color: var(--ink); }

.app-footer {
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 14px 28px;
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
