:root {
  --navy: #0b1324;
  --navy-soft: #111c32;
  --orange: #ff6b35;
  --orange-dark: #ed5420;
  --ink: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --surface: #ffffff;
  --canvas: #f4f6fa;
  --green: #12b76a;
  --red: #f04438;
  --amber: #f79009;
  --blue: #2e6cf6;
  --shadow: 0 18px 50px rgba(16, 24, 40, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; margin: 0; }
body { min-height: 100vh; background: var(--canvas); }
button, input, select { font: inherit; }
button { cursor: pointer; }

.eyebrow {
  margin: 0 0 5px;
  color: #98a2b3;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.muted { color: var(--muted); }

.loading-view {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  color: var(--muted);
}
.loader {
  width: 38px;
  height: 38px;
  border: 3px solid #dce2ec;
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.login-view {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 28px;
  background:
    radial-gradient(circle at 15% 20%, rgba(46,108,246,.18), transparent 32%),
    radial-gradient(circle at 88% 78%, rgba(255,107,53,.16), transparent 28%),
    var(--navy);
}
.login-glow { position: absolute; border-radius: 999px; filter: blur(10px); opacity: .45; }
.login-glow-one { width: 330px; height: 330px; left: -130px; bottom: -130px; background: #2e6cf6; }
.login-glow-two { width: 240px; height: 240px; right: -80px; top: -80px; background: var(--orange); }
.login-card {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  padding: 38px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 28px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 35px 90px rgba(0,0,0,.32);
}
.login-card h1 { margin: 12px 0 8px; font-size: 30px; letter-spacing: -.035em; }
.login-copy { margin: 0 0 28px; line-height: 1.55; }
.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--orange);
  box-shadow: 0 13px 32px rgba(255,107,53,.3);
}
.brand-mark span {
  position: relative;
  display: block;
  width: 28px;
  height: 20px;
  border: 2px solid white;
  border-radius: 4px;
}
.brand-mark span::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 4px;
  border-left: 8px solid white;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}
.brand-mark span::after {
  content: "";
  position: absolute;
  left: 9px;
  bottom: -7px;
  width: 9px;
  height: 2px;
  background: white;
}

label { display: grid; gap: 8px; margin-bottom: 17px; }
label > span { font-size: 13px; font-weight: 700; color: #344054; }
label small { color: #98a2b3; font-size: 11px; }
input, select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #d0d5dd;
  border-radius: 11px;
  color: var(--ink);
  background: white;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
input:focus, select:focus { border-color: #84a9ff; box-shadow: 0 0 0 4px rgba(46,108,246,.11); }
.form-error { min-height: 20px; margin: -4px 0 10px; color: var(--red); font-size: 13px; }
.security-note { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 18px; color: #667085; font-size: 12px; }
.security-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(18,183,106,.12); }

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 750;
  transition: transform .12s, background .15s, border-color .15s, opacity .15s;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .6; transform: none; }
.button-primary { color: white; background: var(--orange); box-shadow: 0 8px 20px rgba(255,107,53,.2); }
.button-primary:hover { background: var(--orange-dark); }
.button-secondary { color: #344054; border-color: #d0d5dd; background: white; }
.button-secondary:hover { border-color: #98a2b3; background: #f9fafb; }
.button-quiet { color: #475467; background: transparent; }
.button-danger { color: #b42318; border-color: #fecdca; background: #fff5f4; }
.button-small { min-height: 34px; padding: 6px 10px; border-radius: 9px; font-size: 12px; }
.button-wide { width: 100%; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 15px 16px;
  color: white;
  background: var(--navy);
  z-index: 30;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 26px; }
.sidebar-brand strong, .sidebar-brand small { display: block; }
.sidebar-brand strong { font-size: 15px; }
.sidebar-brand small { margin-top: 2px; color: #8190aa; font-size: 11px; }
.brand-mark-small { width: 42px; height: 42px; border-radius: 13px; }
.brand-mark-small span { width: 22px; height: 16px; }
.brand-mark-small span::before { left: 7px; top: 3px; border-left-width: 6px; border-top-width: 4px; border-bottom-width: 4px; }
.brand-mark-small span::after { left: 7px; width: 7px; }
.nav { display: grid; gap: 5px; }
.nav-label { margin: 9px 12px 7px; color: #65748f; font-size: 10px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.nav-label-system { margin-top: 24px; }
.nav-item {
  width: 100%;
  min-height: 43px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border: 0;
  border-radius: 11px;
  color: #aab5c8;
  background: transparent;
  text-align: left;
  font-size: 13px;
  font-weight: 650;
}
.nav-item:hover { color: white; background: rgba(255,255,255,.055); }
.nav-item.active { color: white; background: #17233a; box-shadow: inset 3px 0 var(--orange); }
.nav-icon { width: 20px; color: #8493ae; font-size: 18px; text-align: center; }
.nav-item.active .nav-icon { color: var(--orange); }
.sidebar-user {
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 15px;
  background: rgba(255,255,255,.035);
}
.avatar { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 50%; color: white; background: #263654; font-size: 11px; font-weight: 800; }
.sidebar-user-copy { min-width: 0; }
.sidebar-user-copy strong, .sidebar-user-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-copy strong { font-size: 11px; }
.sidebar-user-copy small { margin-top: 3px; color: #71809b; font-size: 9px; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 10px; background: transparent; color: #667085; font-size: 19px; }
.icon-button:hover { background: #f2f4f7; }
.icon-button.dark { color: #8493ae; }
.icon-button.dark:hover { color: white; background: rgba(255,255,255,.07); }

.workspace { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 76px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 30px;
  border-bottom: 1px solid rgba(228,231,236,.9);
  background: rgba(244,246,250,.9);
  backdrop-filter: blur(14px);
}
.topbar h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.topbar-actions { display: flex; gap: 9px; margin-left: auto; }
.mobile-menu { display: none; }
.content { max-width: 1600px; margin: 0 auto; padding: 30px; }
.page-section { display: grid; gap: 22px; }
.hero-row, .section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; }
.hero-row h1, .section-heading h1 { margin: 8px 0 7px; letter-spacing: -.045em; }
.hero-row h1 { max-width: 800px; font-size: clamp(28px, 3vw, 40px); }
.section-heading h1 { font-size: 30px; }
.hero-row p, .section-heading p { margin: 0; max-width: 690px; color: var(--muted); line-height: 1.6; }
.health-pill { width: fit-content; display: flex; align-items: center; gap: 7px; padding: 6px 10px; border-radius: 99px; color: #067647; background: #ecfdf3; font-size: 11px; font-weight: 800; }
.health-pill span { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(18,183,106,.12); }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 15px; }
.metric-card { position: relative; overflow: hidden; min-height: 150px; padding: 20px; border: 1px solid var(--line); border-radius: 19px; background: white; box-shadow: 0 10px 30px rgba(16,24,40,.035); }
.metric-card::after { content: ""; position: absolute; width: 95px; height: 95px; right: -34px; top: -36px; border-radius: 50%; background: var(--tone-bg); }
.metric-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; color: var(--tone); background: var(--tone-bg); font-weight: 850; }
.metric-card strong { display: block; margin-top: 15px; font-size: 28px; letter-spacing: -.04em; }
.metric-card p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.tone-blue { --tone: #2e6cf6; --tone-bg: #edf3ff; }
.tone-green { --tone: #079455; --tone-bg: #ecfdf3; }
.tone-orange { --tone: #e04f16; --tone-bg: #fff2ed; }
.tone-red { --tone: #d92d20; --tone-bg: #fff1f0; }

.panel { overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: white; box-shadow: 0 10px 32px rgba(16,24,40,.035); }
.panel-heading { min-height: 84px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 21px; border-bottom: 1px solid #eef0f4; }
.panel-heading h3 { margin: 0; font-size: 15px; }
.panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.search-box { position: relative; width: min(280px, 100%); display: block; margin: 0; }
.search-box span { position: absolute; left: 12px; top: 9px; color: #98a2b3; font-size: 20px; }
.search-box input { min-height: 40px; padding-left: 38px; background: #f9fafb; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 17px; border-bottom: 1px solid #f0f2f5; text-align: left; white-space: nowrap; }
th { color: #667085; background: #fcfcfd; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
td { color: #344054; font-size: 12px; }
tbody tr:hover { background: #fcfcfd; }
tbody tr:last-child td { border-bottom: 0; }
.table-title { color: var(--ink); font-weight: 760; }
.table-subtitle { display: block; margin-top: 4px; color: #98a2b3; font-size: 10px; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 99px; font-size: 10px; font-weight: 800; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-online, .status-playing, .status-downloading { color: #067647; background: #ecfdf3; }
.status-offline { color: #475467; background: #f2f4f7; }
.status-error { color: #b42318; background: #fef3f2; }
.status-pending { color: #b54708; background: #fffaeb; }
.progress { width: 92px; height: 6px; overflow: hidden; border: 0; border-radius: 10px; background: #eaecf0; }
.progress::-webkit-progress-bar { border-radius: 10px; background: #eaecf0; }
.progress::-webkit-progress-value { border-radius: 10px; background: var(--blue); }
.progress::-moz-progress-bar { border-radius: 10px; background: var(--blue); }
.row-actions { display: flex; gap: 6px; }
.empty-state { padding: 48px 24px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 6px; color: #344054; }

.media-grid, .branch-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; padding: 18px; }
.media-card, .branch-card { padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: #fcfcfd; }
.media-thumb { height: 112px; display: grid; place-items: center; margin-bottom: 14px; border-radius: 13px; color: white; background: linear-gradient(135deg, #17233a, #263a60); font-size: 30px; }
.media-card h3, .branch-card h3 { margin: 0; overflow: hidden; text-overflow: ellipsis; font-size: 14px; white-space: nowrap; }
.media-card p, .branch-card p { margin: 7px 0 14px; color: var(--muted); font-size: 11px; }
.media-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.branch-icon { width: 42px; height: 42px; display: grid; place-items: center; margin-bottom: 16px; border-radius: 12px; color: var(--orange-dark); background: #fff2ed; font-weight: 850; }

.modal { width: min(520px, calc(100% - 30px)); padding: 0; border: 0; border-radius: 22px; color: var(--ink); box-shadow: 0 35px 90px rgba(16,24,40,.28); }
.modal::backdrop { background: rgba(11,19,36,.68); backdrop-filter: blur(4px); }
.modal > form, .modal > div:not(.modal-heading), .modal > .modal-heading { margin-left: 0; margin-right: 0; }
.modal form, .modal-wide { padding: 0; }
.modal-wide { width: min(820px, calc(100% - 30px)); padding: 24px; }
.modal:not(.modal-wide) form { padding: 24px; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.modal-heading h2 { margin: 0; font-size: 22px; letter-spacing: -.03em; }
.modal-close { width: 35px; height: 35px; border: 0; border-radius: 10px; color: #667085; background: #f2f4f7; font-size: 22px; line-height: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }
.step-card { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 15px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: #fcfcfd; }
.step-card + .step-card { margin-top: 14px; }
.step-number { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--navy); font-size: 12px; font-weight: 850; }
.step-card h3 { margin: 0 0 5px; font-size: 14px; }
.step-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.step-form { align-items: start; }
.step-fields { min-width: 0; }
.step-fields .form-grid { margin-top: 16px; }
.code-result { display: grid; place-items: center; gap: 5px; margin: 12px 0; padding: 17px; border: 1px dashed #f4a481; border-radius: 15px; background: #fff7f3; }
.code-result span { color: #9a3412; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.code-result strong { color: #7c2d12; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 30px; letter-spacing: .1em; }
.code-result small { color: #c2410c; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); margin-top: 14px; }
.form-grid label { margin: 0; }
.file-drop { padding: 20px; border: 1px dashed #98a2b3; border-radius: 14px; background: #f9fafb; }
.playlist-options { max-height: 330px; overflow-y: auto; display: grid; gap: 9px; padding-right: 4px; }
.playlist-option { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fcfcfd; }
.playlist-option input { width: 18px; min-height: 18px; margin: 0; }
.playlist-option strong { display: block; font-size: 12px; }
.playlist-option small { display: block; margin-top: 3px; color: var(--muted); }
.schedule-box { margin-top: 17px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 13px; background: #fcfcfd; }
.schedule-box summary { cursor: pointer; color: #344054; font-size: 12px; font-weight: 750; }

.toast-region { position: fixed; z-index: 100; top: 18px; right: 18px; display: grid; gap: 9px; width: min(360px, calc(100% - 36px)); }
.toast { padding: 13px 15px; border: 1px solid var(--line); border-left: 4px solid var(--green); border-radius: 12px; color: #344054; background: white; box-shadow: var(--shadow); font-size: 12px; animation: toast-in .2s ease-out; }
.toast.error { border-left-color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

@media (max-width: 1120px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .media-grid, .branch-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -280px; width: 260px; transition: left .2s ease; box-shadow: 20px 0 60px rgba(0,0,0,.25); }
  body.menu-open .sidebar { left: 0; }
  .mobile-menu { display: block; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px; }
  .hero-row, .section-heading { align-items: flex-start; flex-direction: column; }
  .topbar-actions .button-secondary { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .step-card { grid-template-columns: auto minmax(0,1fr); }
  .step-card > .button { grid-column: 2; justify-self: start; }
}

@media (max-width: 560px) {
  .login-card { padding: 27px 22px; border-radius: 23px; }
  .metrics-grid, .media-grid, .branch-grid { grid-template-columns: 1fr; }
  .topbar-actions .button { min-height: 38px; padding: 8px 11px; }
  .hero-row h1 { font-size: 28px; }
  .panel-heading { align-items: stretch; flex-direction: column; }
  .search-box { width: 100%; }
  .modal-wide { padding: 18px; }
  .step-card { grid-template-columns: 1fr; }
  .step-card > .button { grid-column: 1; }
  .form-grid.two { grid-template-columns: 1fr; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .button { width: 100%; }
}
