:root {
  --primary: #5d87ff;
  --primary-dark: #4570ea;
  --primary-soft: #ecf2ff;
  --cyan: #49beff;
  --cyan-soft: #e8f7ff;
  --success: #13deb9;
  --success-soft: #e6fffa;
  --warn: #ffae1f;
  --warn-soft: #fff6e5;
  --danger: #fa896b;
  --danger-soft: #fdece8;
  --gold: #c9a227;
  --text: #2a3547;
  --text-muted: #7c8fac;
  --border: #ebf1f6;
  --page: #f6f9fc;
  --card: #ffffff;
  --sidebar: #ffffff;
  --radius: 7px;
  --shadow: 0 9px 17.5px rgba(0, 0, 0, 0.05);
  --font: "Plus Jakarta Sans", Inter, ui-sans-serif, system-ui, sans-serif;
  --sidebar-w: 270px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--page); color: var(--text); font-family: var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: var(--primary); color: #fff; border: 0; border-radius: var(--radius); padding: 10px 16px; font-weight: 600; }
button:hover { background: var(--primary-dark); }
button.ghost { background: var(--primary-soft); color: var(--primary); }
button.ghost:hover { background: #dbe6ff; }
button.danger { background: var(--danger-soft); color: #c2410c; }
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.error { color: var(--danger); min-height: 1.2em; }
.grow { flex: 1; }
code, kbd { font-size: 0.82em; background: var(--primary-soft); color: var(--primary); padding: 2px 7px; border-radius: 6px; }
kbd { font-family: inherit; }

.login { min-height: 100%; display: grid; place-items: center; padding: 24px; background: linear-gradient(180deg, #ecf2ff 0%, #f6f9fc 40%); }
.login-card { width: min(440px, 100%); background: var(--card); padding: 36px; border-radius: 12px; box-shadow: var(--shadow); }
.eyebrow { letter-spacing: 0.12em; text-transform: uppercase; font-size: 11px; color: var(--primary); font-weight: 700; margin: 0; }
.login-card h1 { margin: 8px 0 12px; font-size: 28px; letter-spacing: -0.03em; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; margin: 14px 0; }
.login-card input { padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: #fff; }
.login-card input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.hint { font-size: 12px; }

.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100%; background: var(--page); }
aside { background: var(--sidebar); color: var(--text); padding: 16px 14px; display: flex; flex-direction: column; border-right: 1px solid var(--border); height: 100vh; position: sticky; top: 0; overflow: hidden; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 12px; }
.logo-mark {
  width: 40px; height: 40px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  display: grid; place-items: center; color: #fff; font-weight: 800; flex-shrink: 0;
}
.brand strong { display: block; font-size: 18px; letter-spacing: -0.03em; }
.brand span { color: var(--text-muted); font-size: 12px; }
.nav-group { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); padding: 10px 12px 4px; }
nav { display: flex; flex-direction: column; gap: 2px; overflow: auto; flex: 1; min-height: 0; }
nav button {
  background: transparent; color: var(--text); text-align: left; font-weight: 500;
  border-radius: var(--radius); padding: 7px 12px; display: flex; align-items: center; gap: 10px;
}
nav button svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.75; }
nav button:hover { background: var(--page); }
nav button.active { background: var(--primary); color: #fff; }
nav button.active svg { opacity: 1; }
.aside-foot { margin-top: auto; padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.user-card { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 10px; background: var(--page); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.aside-foot button { width: 100%; }

.workspace { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
.top { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 20px 28px 8px; }
.top h2 { margin: 0; font-size: 22px; letter-spacing: -0.03em; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions input {
  padding: 10px 14px; border-radius: 7px; border: 1px solid var(--border); min-width: 240px; background: #fff;
}
.actions input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }

main { padding: 8px 28px 48px; overflow: auto; }

.saas {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 24px;
}
.card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 24px;
}
.card h3 { margin: 0 0 16px; font-size: 18px; letter-spacing: -0.02em; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.kpi b { display: block; font-size: 30px; letter-spacing: -0.04em; margin: 8px 0 4px; }
.delta { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }
.kpi-icon {
  width: 48px; height: 48px; border-radius: 50%; background: var(--cyan-soft); color: var(--cyan);
  display: grid; place-items: center; font-size: 20px; font-weight: 700;
}
.kpi-row { display: flex; justify-content: space-between; align-items: flex-start; }
.stack { display: flex; flex-direction: column; gap: 24px; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.donut-wrap { display: flex; align-items: center; gap: 20px; margin-top: 8px; }
.donut {
  width: 110px; height: 110px; border-radius: 50%;
  background: conic-gradient(var(--primary) 0 var(--p1, 70%), var(--primary-soft) var(--p1, 70%) 100%);
  mask: radial-gradient(transparent 58%, #000 59%);
  -webkit-mask: radial-gradient(transparent 58%, #000 59%);
  flex-shrink: 0;
}
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 72px 14px 1fr; gap: 12px; padding: 10px 0; }
.time { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.bullet { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--primary); margin-top: 4px; background: #fff; }
.bullet.warn { border-color: var(--warn); }
.bullet.ok { border-color: var(--success); }
.bullet.danger { border-color: var(--danger); }

.perf { width: 100%; border-collapse: collapse; }
.perf th, .perf td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
.perf th { color: var(--text-muted); font-weight: 600; font-size: 13px; text-transform: none; letter-spacing: 0; }
.perf tr { cursor: pointer; }
.perf tr:hover td { background: var(--page); }

.chart { width: 100%; height: 280px; display: block; }
.spark { width: 100%; height: 64px; display: block; margin-top: 12px; }

.dash { display: block; }
.note, .queue { background: var(--card); border-radius: 12px; padding: 24px; box-shadow: var(--shadow); }
.note label, .queue label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.note input, .note textarea, .queue input, .queue textarea { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); }

table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: top; }
thead { position: sticky; top: 0; background: var(--card); z-index: 1; }
th { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: none; letter-spacing: 0; }
tr { cursor: pointer; }
tr:hover td { background: var(--page); }
.badge { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; background: var(--primary-soft); color: var(--primary); }
.badge.ok { background: var(--success-soft); color: #0f766e; }
.badge.warn { background: var(--warn-soft); color: #b45309; }
.badge.gold { background: #fff7d6; color: #854d0e; }
.badge.danger { background: var(--danger-soft); color: #c2410c; }

dialog { border: 0; border-radius: 12px; padding: 0; width: min(820px, 96vw); box-shadow: 0 24px 80px rgba(42, 53, 71, 0.18); }
dialog::backdrop { background: rgba(42, 53, 71, 0.35); }
#editor-form header, #editor-form footer, #csv-form header, #csv-form footer { display: flex; align-items: center; gap: 12px; padding: 16px 20px; }
#editor-form h3, #csv-form h3 { margin: 0; }
.fields { padding: 0 20px 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-height: 65vh; overflow: auto; }
.fields label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 650; }
.fields label.wide { grid-column: 1 / -1; }
.fields input, .fields select, .fields textarea { padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--border); }
.fields textarea { min-height: 88px; resize: vertical; }
.check { flex-direction: row !important; align-items: center; gap: 8px; }
.check input { width: 18px; height: 18px; }
#csv-text { width: calc(100% - 40px); margin: 0 20px 12px; min-height: 180px; border-radius: var(--radius); border: 1px solid var(--border); padding: 12px; }
.pad { padding: 0 20px; }

.palette { width: min(560px, 94vw); padding: 12px; }
.palette input { width: 100%; padding: 12px; border-radius: var(--radius); border: 1px solid var(--border); }
#palette-list button { display: block; width: 100%; text-align: left; background: transparent; color: var(--text); margin-top: 4px; font-weight: 600; }
#palette-list button:hover, #palette-list button.active { background: var(--primary-soft); color: var(--primary); }

.media-list {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.media-row {
  display: grid;
  grid-template-columns: 36px 56px minmax(220px, 1.8fr) minmax(140px, 1fr) 150px 110px 40px;
  align-items: center;
  gap: 8px 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  position: relative;
}
.media-row:last-child { border-bottom: 0; }
.media-row:hover { background: #fafcfe; }
.media-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }
.thumb {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--primary-soft);
  display: block;
}
.thumb-fallback {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}
.title-cell { min-width: 0; }
.title-cell strong { display: block; font-size: 15px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-cell span { display: block; color: var(--text-muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-date { color: var(--text-muted); font-size: 14px; }
.media-status { font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.media-status .dot { width: 8px; height: 8px; margin: 0; }
.media-status .dot.ok { background: var(--success); }
.media-status .dot.warn { background: var(--danger); }
.media-metric { font-size: 16px; font-weight: 700; text-align: right; letter-spacing: -0.02em; }
.kebab {
  background: transparent;
  color: var(--text-muted);
  padding: 6px 8px;
  font-size: 20px;
  line-height: 1;
  border-radius: 8px;
}
.kebab:hover { background: var(--page); color: var(--text); }
.row-menu {
  position: absolute;
  right: 16px;
  top: 52px;
  background: #fff;
  border-radius: 10px;
  box-shadow: var(--shadow);
  min-width: 160px;
  z-index: 5;
  padding: 6px;
  border: 1px solid var(--border);
}
.row-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  font-weight: 500;
  padding: 8px 10px;
}
.row-menu button:hover { background: var(--primary-soft); color: var(--primary); }

.mall-hero {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  min-height: 220px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  background: #1b2430;
}
.mall-hero img { width: 100%; height: 280px; object-fit: cover; display: block; opacity: 0.92; }
.mall-hero .veil {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(15,23,42,0.15) 0%, rgba(15,23,42,0.72) 100%);
}
.mall-hero .copy { position: absolute; left: 24px; right: 24px; bottom: 20px; color: #fff; }
.mall-hero h3 { margin: 0 0 6px; font-size: 28px; letter-spacing: -0.03em; }
.mall-hero p { margin: 0; color: rgba(255,255,255,0.88); font-size: 14px; }
.mall-hero .chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.mall-hero .chip {
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
}
.crumb { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; font-size: 13px; }
.crumb button { background: transparent; color: var(--primary); padding: 0; font-weight: 600; }
.crumb button:hover { background: transparent; text-decoration: underline; }
.brand-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 20px;
}
.brand-hero h3 { margin: 0 0 4px; font-size: 24px; letter-spacing: -0.03em; }
.brand-hero p { margin: 0; }
.brand-hero .thumb, .brand-hero .thumb-fallback { width: 64px; height: 64px; font-size: 24px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filters button {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
  font-weight: 600;
  padding: 8px 12px;
}
.filters button:hover { background: var(--page); }
.filters button.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.cover {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  object-fit: cover;
  display: block;
  background: var(--primary-soft);
}
.stats-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.stats-row .chip-stat {
  background: var(--card);
  box-shadow: var(--shadow);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
}
.stats-row b { display: block; font-size: 18px; letter-spacing: -0.03em; }

.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-toolbar h3 { margin: 0; font-size: 20px; }
.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-bottom: 8px; color: var(--text-muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal .day { background: var(--card); box-shadow: var(--shadow); border-radius: 12px; min-height: 118px; padding: 10px; font-size: 12px; cursor: pointer; border: 2px solid transparent; }
.cal .day:hover { border-color: var(--primary-soft); }
.cal .day.today { border-color: var(--primary); }
.cal .day.selected { background: var(--primary-soft); }
.cal .day.pad { opacity: 0.4; cursor: default; }
.cal .day b { display: block; margin-bottom: 6px; }
.cal .holiday { color: var(--danger); font-size: 10px; font-weight: 700; margin-bottom: 4px; }
.cal .pill { display: block; background: var(--primary-soft); color: var(--primary); border-radius: 6px; padding: 2px 6px; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.cal .pill.event { background: var(--success-soft); color: #0f766e; }
.cal .pill.warn { background: var(--warn-soft); color: #b45309; }
.cal .more { color: var(--text-muted); font-weight: 700; }
.agenda { margin-top: 16px; }
.agenda h3 { margin: 0 0 12px; }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.media-card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
}
.media-card img { width: 100%; height: 140px; object-fit: cover; display: block; background: var(--page); }
.media-card .body { padding: 12px 14px 14px; }
.media-card strong { display: block; font-size: 13px; }
.media-card span { color: var(--text-muted); font-size: 12px; }

.lightbox { width: min(880px, 96vw); padding: 16px; border: 0; border-radius: 12px; }
.lightbox img { width: 100%; max-height: 70vh; object-fit: contain; background: #0f172a; border-radius: 8px; }
.lightbox footer { display: flex; align-items: center; gap: 8px; margin-top: 12px; }

.tax-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.tax-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 999px;
  padding: 6px 10px 6px 12px;
  font-size: 13px;
  font-weight: 600;
}
.tax-chip button {
  background: transparent;
  color: var(--primary);
  padding: 0 4px;
  font-size: 16px;
  line-height: 1;
}
.tax-chip .count { color: var(--text-muted); font-weight: 500; }
.tax-add { display: flex; gap: 8px; }
.tax-add input { flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: 7px; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.settings-grid .card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; margin: 10px 0; }
.settings-grid input, .settings-grid textarea { padding: 10px 12px; border: 1px solid var(--border); border-radius: 7px; }
.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
}
.switch input {
  appearance: none;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #e2e8f0;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  border: 0;
  padding: 0;
}
.switch input:checked { background: var(--primary); }
.switch input::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: left 0.15s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.2);
}
.switch input:checked::after { left: 21px; }

.badge.role-owner { background: #fff7d6; color: #854d0e; }
.badge.role-admin { background: var(--primary-soft); color: var(--primary); }
.badge.role-editor { background: var(--success-soft); color: #0f766e; }
.badge.role-publisher { background: var(--warn-soft); color: #b45309; }
.badge.role-viewer { background: var(--page); color: var(--text-muted); }

@media (max-width: 1100px) {
  .saas { grid-template-columns: 1fr; }
}
@media (max-width: 840px) {
  .app { grid-template-columns: 1fr; }
  aside { flex-direction: row; flex-wrap: wrap; align-items: center; }
  nav { flex-direction: row; flex-wrap: wrap; }
  .aside-foot { margin: 0 0 0 auto; }
}
