:root {
  --orange: #f58220;
  --orange-dark: #d9630d;
  --blue: #003b70;
  --ink: #172333;
  --muted: #738095;
  --line: #e6ebf1;
  --soft: #f5f7fa;
  --green: #20a36a;
  --red: #d94d55;
  --shadow: 0 16px 50px rgba(20, 40, 75, .08);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--soft); color: var(--ink); font-family: Montserrat, Arial, sans-serif; font-size: 14px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { color: var(--orange); font-size: 10px; font-weight: 800; letter-spacing: .14em; margin: 0 0 9px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 26px; margin-bottom: 0; }
h2 { font-size: 21px; margin-bottom: 8px; }
h3 { font-size: 15px; margin-bottom: 6px; }

.login-shell { align-items: center; background: radial-gradient(circle at 75% 15%, #ffb56d 0, transparent 22%), linear-gradient(135deg, #002b54, #07538c); display: flex; justify-content: center; min-height: 100vh; padding: 24px; }
.login-card { background: white; border-radius: 22px; box-shadow: 0 25px 80px rgba(0,0,0,.24); max-width: 430px; padding: 42px; width: 100%; }
.brand-mark { color: var(--blue); font-size: 22px; font-weight: 800; letter-spacing: -.06em; }
.login-card h1 { margin-top: 4px; }
.stack-form { display: grid; gap: 15px; margin-top: 28px; }
label { color: #42526a; display: grid; font-size: 12px; font-weight: 700; gap: 7px; }
input, select, textarea { background: white; border: 1px solid #d8e0e9; border-radius: 9px; color: var(--ink); min-height: 40px; outline: none; padding: 9px 11px; }
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(245,130,32,.13); }
.form-error { color: var(--red); min-height: 18px; margin: 0; }
.primary, .secondary, .ghost, .danger, .file-button { border: 0; border-radius: 9px; font-weight: 700; min-height: 40px; padding: 0 15px; }
.primary { background: var(--orange); color: white; }
.primary:hover { background: var(--orange-dark); }
.secondary { background: #fff2e7; color: var(--orange-dark); }
.ghost { background: transparent; color: var(--blue); }
.danger { background: #fff0f0; color: var(--red); }
.wide { width: 100%; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar { background: white; border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 28px 16px 18px; width: 240px; }
.sidebar-brand { align-items: baseline; display: flex; gap: 8px; padding: 0 13px 42px; }
.sidebar-brand span { color: var(--muted); font-size: 12px; font-weight: 600; }
.main-nav { display: grid; gap: 8px; }
.nav-item { align-items: center; background: transparent; border: 0; border-radius: 10px; color: #6b788c; display: flex; font-weight: 600; gap: 12px; min-height: 46px; padding: 0 14px; text-align: left; }
.nav-item span { color: var(--orange); font-size: 18px; width: 17px; }
.nav-item:hover, .nav-item.active { background: #fff3e9; color: var(--orange-dark); }
.sidebar-footer { align-items: center; color: var(--muted); display: flex; font-size: 11px; gap: 8px; margin-top: auto; padding: 12px 14px; }
.status-dot, .online-dot { background: var(--green); border-radius: 50%; display: inline-block; height: 8px; width: 8px; }
.offline-dot { background: #bbc5d0; }
.main-shell { flex: 1; min-width: 0; }
.topbar { align-items: center; background: rgba(255,255,255,.87); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; padding: 28px 44px; }
.topbar-actions { align-items: center; display: flex; gap: 15px; }
.content { margin: 0 auto; max-width: 1450px; padding: 36px 44px 80px; }
.view { display: none; }
.view.active-view { display: block; }
.hero-card { align-items: center; background: linear-gradient(112deg, var(--blue), #076a99); border-radius: 19px; color: white; display: flex; justify-content: space-between; margin-bottom: 25px; min-height: 185px; overflow: hidden; padding: 32px 38px; position: relative; }
.hero-card h2 { font-size: 25px; max-width: 580px; }
.hero-card p:not(.eyebrow) { color: #cde2ef; margin-bottom: 0; }
.hero-orb { align-items: center; background: radial-gradient(circle, #ffbd74, var(--orange)); border-radius: 50%; box-shadow: 0 0 0 20px rgba(255,255,255,.06), 0 0 0 50px rgba(255,255,255,.05); color: white; display: flex; font-size: 55px; height: 120px; justify-content: center; margin-right: 65px; width: 120px; }
.stats-grid { display: grid; gap: 17px; grid-template-columns: repeat(4, 1fr); margin-bottom: 38px; }
.stat-card, .table-card, .media-card, .channel-card, .device-card, .group-card { background: white; border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); }
.stat-card { padding: 20px; }
.stat-card .stat-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.stat-card .stat-value { color: var(--blue); font-size: 30px; font-weight: 800; margin-top: 10px; }
.section-header { align-items: flex-end; display: flex; justify-content: space-between; margin: 35px 0 18px; }
.section-header h2 { margin-bottom: 4px; }
.section-header p:not(.eyebrow) { margin-bottom: 0; }
.table-card { overflow: auto; }
table { border-collapse: collapse; min-width: 670px; width: 100%; }
th, td { border-bottom: 1px solid var(--line); padding: 14px 17px; text-align: left; }
th { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
.status-label { align-items: center; display: inline-flex; gap: 7px; }
.upload-box { align-items: center; background: white; border: 1px dashed #cbd5e1; border-radius: 15px; display: flex; gap: 18px; padding: 20px; }
.upload-icon { align-items: center; background: #fff1e5; border-radius: 12px; color: var(--orange); display: flex; font-size: 25px; height: 52px; justify-content: center; width: 52px; }
.upload-box p { margin-bottom: 0; margin-top: 4px; }
.file-button { align-items: center; background: #f1f4f7; color: var(--blue); display: inline-flex; margin-left: auto; }
.file-button input { display: none; }
.compact-field { min-width: 170px; }
.media-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); margin-top: 24px; }
.media-card { overflow: hidden; }
.media-preview { align-items: center; background: #eaf0f5; display: flex; height: 145px; justify-content: center; overflow: hidden; }
.media-preview img, .media-preview video { height: 100%; object-fit: cover; width: 100%; }
.media-preview .video-label { color: var(--blue); font-size: 30px; }
.media-details { padding: 14px; }
.media-name { font-size: 12px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-meta { color: var(--muted); font-size: 11px; margin-top: 7px; }
.media-actions { display: flex; gap: 7px; margin-top: 12px; }
.small-button { background: #f4f6f8; border: 0; border-radius: 7px; color: var(--blue); font-size: 11px; font-weight: 700; padding: 8px 10px; }
.small-button.danger { background: #fff0f0; color: var(--red); }
.channel-list, .device-list, .group-list { display: grid; gap: 17px; }
.channel-card, .device-card, .group-card { padding: 22px; }
.card-top { align-items: flex-start; display: flex; gap: 14px; justify-content: space-between; }
.card-actions { display: flex; gap: 7px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.inline-form label { flex: 1; min-width: 150px; }
.playlist { background: #f7f9fb; border-radius: 11px; margin-top: 19px; padding: 9px; }
.playlist-row { align-items: center; background: white; border: 1px solid var(--line); border-radius: 8px; display: flex; gap: 10px; margin: 5px 0; min-height: 48px; padding: 6px 9px; }
.playlist-index { color: var(--orange); font-weight: 800; width: 22px; }
.playlist-name { flex: 1; font-size: 12px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.playlist-actions { display: flex; gap: 4px; }
.playlist-actions button { background: transparent; border: 0; color: var(--muted); padding: 5px; }
.add-row { align-items: end; display: flex; gap: 9px; margin-top: 13px; }
.add-row label { flex: 1; }
.device-card { display: grid; gap: 16px; grid-template-columns: 1fr 2fr; }
.device-ident { display: flex; gap: 13px; }
.device-icon { align-items: center; background: #edf4fb; border-radius: 12px; color: var(--blue); display: flex; font-size: 24px; height: 48px; justify-content: center; width: 48px; }
.device-code { color: var(--muted); font-size: 11px; margin-top: 6px; }
.device-fields { display: grid; gap: 10px; grid-template-columns: repeat(3, 1fr); }
.device-fields .wide-field { grid-column: span 3; }
.group-card { align-items: center; display: grid; gap: 18px; grid-template-columns: 1fr 1fr auto; }
.toast { background: var(--ink); border-radius: 9px; bottom: 25px; color: white; left: 50%; opacity: 0; padding: 12px 17px; pointer-events: none; position: fixed; transform: translate(-50%, 15px); transition: .25s ease; z-index: 20; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1000px) {
  .sidebar { width: 205px; }
  .topbar, .content { padding-left: 25px; padding-right: 25px; }
  .device-card { grid-template-columns: 1fr; }
  .device-fields { grid-template-columns: repeat(2, 1fr); }
  .device-fields .wide-field { grid-column: span 2; }
}
@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar { border-bottom: 1px solid var(--line); border-right: 0; padding: 15px; width: 100%; }
  .sidebar-brand { padding: 0 4px 14px; }
  .main-nav { display: flex; overflow: auto; }
  .nav-item { min-width: max-content; }
  .sidebar-footer { display: none; }
  .topbar { padding: 19px 18px; }
  .topbar-actions .muted { display: none; }
  .content { padding: 22px 18px 50px; }
  .hero-card { padding: 25px; }
  .hero-orb { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .section-header { align-items: flex-start; flex-direction: column; gap: 13px; }
  .upload-box { align-items: stretch; flex-direction: column; }
  .file-button { margin-left: 0; justify-content: center; }
  .group-card { align-items: stretch; grid-template-columns: 1fr; }
}
