:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a25;
  --bg-card-hover: #22222f;
  --bg-input: #15151f;
  --border: #2a2a38;
  --border-light: #333345;
  --text-primary: #e8e8f0;
  --text-secondary: #9898a8;
  --text-muted: #6a6a78;
  --gold: #c9a84c;
  --gold-light: #ddbf6a;
  --gold-dark: #a88a35;
  --gold-bg: rgba(201, 168, 76, 0.08);
  --green: #4caf7c;
  --green-bg: rgba(76, 175, 124, 0.1);
  --red: #e05555;
  --red-bg: rgba(224, 85, 85, 0.1);
  --blue: #5588cc;
  --blue-bg: rgba(85, 136, 204, 0.1);
  --purple: #8866bb;
  --purple-bg: rgba(136, 102, 187, 0.1);
  --orange: #cc8844;
  --orange-bg: rgba(204, 136, 68, 0.1);
  --sidebar-width: 220px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
}

#app { display: flex; min-height: 100vh; }

/* ─── SIDEBAR ─────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
}
.logo { padding: 8px 20px 24px; display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 24px; color: var(--gold); }
.logo-text { font-family: 'Playfair Display', serif; font-size: 20px; font-weight: 700; color: var(--text-primary); }
.nav-links { list-style: none; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: var(--text-secondary); text-decoration: none; font-size: 13px; font-weight: 500; transition: all var(--transition); border-left: 3px solid transparent; }
.nav-link:hover { color: var(--text-primary); background: var(--bg-card); }
.nav-link.active { color: var(--gold); background: var(--gold-bg); border-left-color: var(--gold); }
.nav-icon { width: 18px; text-align: center; font-size: 14px; }

/* ─── MAIN CONTENT ────────────────────────────────── */
#content { margin-left: var(--sidebar-width); flex: 1; padding: 32px 40px; min-height: 100vh; }

/* ─── PAGE HEADER ─────────────────────────────────── */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.page-header h1 { font-family: 'Playfair Display', serif; font-size: 28px; font-weight: 700; color: var(--text-primary); }
.page-header h1 .subtitle { font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 400; color: var(--text-muted); margin-left: 12px; }

/* ─── BUTTONS ─────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 500; cursor: pointer; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-primary); transition: all var(--transition); text-decoration: none; }
.btn:hover { background: var(--bg-card-hover); border-color: var(--border-light); }
.btn-primary { background: var(--gold); color: #000; border-color: var(--gold); }
.btn-primary:hover { background: var(--gold-light); border-color: var(--gold-light); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-bg); border-color: var(--red); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-card); }

/* ─── TABS ────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.tab { padding: 10px 18px; font-size: 13px; font-weight: 500; color: var(--text-secondary); cursor: pointer; border: none; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all var(--transition); }
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--gold); border-bottom-color: var(--gold); }

/* ─── CARDS ───────────────────────────────────────── */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; transition: all var(--transition); }
.card:hover { border-color: var(--border-light); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; color: var(--text-primary); }
.card-meta { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.card-body { font-size: 13px; color: var(--text-secondary); margin-top: 10px; }
.card-actions { display: flex; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

/* ─── STAT CARDS ──────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; }
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-family: 'Playfair Display', serif; font-size: 28px; font-weight: 700; color: var(--text-primary); }
.stat-value.gold { color: var(--gold); }
.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-detail { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ─── BADGES ──────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.badge-gold { background: var(--gold-bg); color: var(--gold); border: 1px solid rgba(201,168,76,0.2); }
.badge-green { background: var(--green-bg); color: var(--green); border: 1px solid rgba(76,175,124,0.2); }
.badge-blue { background: var(--blue-bg); color: var(--blue); border: 1px solid rgba(85,136,204,0.2); }
.badge-red { background: var(--red-bg); color: var(--red); border: 1px solid rgba(224,85,85,0.2); }
.badge-purple { background: var(--purple-bg); color: var(--purple); border: 1px solid rgba(136,102,187,0.2); }
.badge-orange { background: var(--orange-bg); color: var(--orange); border: 1px solid rgba(204,136,68,0.2); }
.badge-muted { background: rgba(106,106,120,0.1); color: var(--text-muted); border: 1px solid rgba(106,106,120,0.2); }

/* ─── TABLES ──────────────────────────────────────── */
.table-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 12px 16px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); background: var(--bg-secondary); border-bottom: 1px solid var(--border); }
td { padding: 12px 16px; font-size: 13px; border-bottom: 1px solid var(--border); color: var(--text-secondary); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-card-hover); }
td .primary { color: var(--text-primary); font-weight: 500; }

/* ─── FORMS ───────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.3px; }
.form-control { width: 100%; padding: 9px 12px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-primary); font-size: 13px; font-family: inherit; transition: border-color var(--transition); }
.form-control:focus { outline: none; border-color: var(--gold); }
textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239898a8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ─── FILTERS ─────────────────────────────────────── */
.filters { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.filter-btn { padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 500; cursor: pointer; border: 1px solid var(--border); background: transparent; color: var(--text-secondary); transition: all var(--transition); }
.filter-btn:hover { border-color: var(--border-light); color: var(--text-primary); }
.filter-btn.active { background: var(--gold-bg); border-color: var(--gold); color: var(--gold); }
.search-input { padding: 7px 14px 7px 32px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 20px; color: var(--text-primary); font-size: 13px; width: 240px; transition: border-color var(--transition); }
.search-input:focus { outline: none; border-color: var(--gold); }
.search-wrap { position: relative; }
.search-wrap::before { content: '\2315'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 14px; }

/* ─── MODAL ───────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-overlay.hidden { display: none; }
.modal { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 90%; max-width: 600px; max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-family: 'Playfair Display', serif; font-size: 18px; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 22px; cursor: pointer; padding: 4px; line-height: 1; }
.modal-close:hover { color: var(--text-primary); }
#modal-body { padding: 24px; }

/* ─── TOAST ───────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 20px; font-size: 13px; color: var(--text-primary); box-shadow: var(--shadow); animation: slideIn 0.3s ease; max-width: 360px; }
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── TEMPLATE PREVIEW ────────────────────────────── */
.template-preview { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; font-size: 13px; line-height: 1.6; white-space: pre-wrap; color: var(--text-secondary); max-height: 400px; overflow-y: auto; }
.template-preview .placeholder { background: var(--gold-bg); color: var(--gold); padding: 1px 4px; border-radius: 3px; font-weight: 600; }

/* ─── PROGRAM BUILDER ─────────────────────────────── */
.program-builder { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.program-piece { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 6px; cursor: pointer; transition: all var(--transition); }
.program-piece:hover { border-color: var(--gold); background: var(--gold-bg); }
.program-piece.in-program { border-color: var(--gold); background: var(--gold-bg); }
.program-piece .piece-composer { font-size: 11px; color: var(--text-muted); }
.program-piece .piece-title { font-size: 13px; color: var(--text-primary); font-weight: 500; }
.program-piece .piece-duration { font-size: 12px; color: var(--text-secondary); min-width: 40px; text-align: right; }
.duration-bar { width: 100%; height: 6px; background: var(--bg-input); border-radius: 3px; overflow: hidden; margin-top: 12px; }
.duration-bar-fill { height: 100%; background: var(--gold); border-radius: 3px; transition: width 0.3s ease; }
.duration-bar-fill.over { background: var(--red); }
.duration-label { font-size: 12px; color: var(--text-secondary); margin-top: 6px; display: flex; justify-content: space-between; }

/* ─── SECTION HEADERS ─────────────────────────────── */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }

/* ─── EMPTY STATE ─────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 36px; margin-bottom: 12px; }
.empty-state .message { font-size: 14px; }

/* ─── LIST VIEW ───────────────────────────────────── */
.list-item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--border); transition: background var(--transition); cursor: pointer; }
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--bg-card-hover); }
.list-item-icon { width: 36px; height: 36px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.list-item-content { flex: 1; min-width: 0; }
.list-item-title { font-size: 14px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-sub { font-size: 12px; color: var(--text-secondary); }
.list-item-right { text-align: right; flex-shrink: 0; }

/* ─── MOBILE BAR ──────────────────────────────────── */
#mobile-bar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 16px;
  z-index: 200;
  gap: 14px;
}
#mobile-title { font-family: 'Playfair Display', serif; font-size: 17px; font-weight: 700; color: var(--text-primary); }
#hamburger { background: none; border: none; cursor: pointer; display: flex; flex-direction: column; gap: 5px; padding: 4px; }
#hamburger span { display: block; width: 22px; height: 2px; background: var(--text-primary); border-radius: 2px; }
#nav-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 150; }
#nav-overlay.open { display: block; }

/* ─── RESPONSIVE ──────────────────────────────────── */
@media (max-width: 768px) {
  #mobile-bar { display: flex; }
  #sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 160;
    top: 0;
    width: 260px;
    padding-top: 60px;
  }
  #sidebar.open { transform: translateX(0); }
  #content { margin-left: 0; padding: 70px 16px 20px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-header h1 { font-size: 22px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .program-builder { grid-template-columns: 1fr; }
  table { font-size: 12px; }
  th, td { padding: 8px 10px; }
  .modal { width: 95vw; }
}
