:root {
  --bg: #f7f3ec;
  --card: #fffdf8;
  --text: #2f3a34;
  --muted: #8b8176;
  --primary: #4f6f64;
  --primary-dark: #385249;
  --soft: #e7efe7;
  --line: #efe8dc;
  --danger: #b65b4b;
  --warning: #a36a1e;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

.app { min-height: 100vh; }
.hidden { display: none !important; }
.brand { color: var(--primary); font-weight: 800; letter-spacing: 1px; }

.login-card {
  max-width: 420px;
  margin: 12vh auto 0;
  padding: 34px;
  background: var(--card);
  border-radius: 26px;
  box-shadow: 0 20px 60px rgba(74, 61, 47, 0.08);
}

h1, h2, p { margin-top: 0; }
p { color: var(--muted); line-height: 1.7; }
label { display: block; margin: 18px 0; font-weight: 700; }
input, select, textarea {
  width: 100%;
  margin-top: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font: inherit;
}
textarea { min-height: 72px; resize: vertical; }
button {
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
button.ghost { background: var(--soft); color: var(--primary); }
button.warn { background: #f6e8e2; color: var(--danger); }
button + button { margin-left: 8px; }
code {
  padding: 2px 6px;
  border-radius: 8px;
  background: #f1ece3;
  color: var(--primary-dark);
}
.hint { margin-top: 16px; color: var(--muted); font-size: 13px; line-height: 1.6; }

.dashboard {
  display: grid;
  grid-template-columns: 246px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: #fffdf8;
  border-right: 1px solid var(--line);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 24px;
}

.brand-dot {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  object-fit: cover;
  background: #fff;
  box-shadow: 0 6px 16px rgba(79, 111, 100, 0.12);
}

.brand-title { font-weight: 900; color: var(--text); }
.brand-subtitle { margin-top: 4px; color: var(--muted); font-size: 12px; }

.nav { display: grid; gap: 8px; }
.nav-item {
  width: 100%;
  padding: 13px 14px;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}
.nav-item.active,
.nav-item:hover {
  background: var(--soft);
  color: var(--primary);
}

.main-panel {
  min-width: 0;
  padding: 28px 30px 42px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.topbar h1 { margin: 6px 0 0; }
.crumb { color: var(--primary); font-size: 13px; font-weight: 800; }
.top-actions { display: flex; gap: 10px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.metric {
  padding: 22px;
  background: var(--card);
  border-radius: 22px;
  box-shadow: 0 12px 30px rgba(74, 61, 47, 0.06);
}
.metric .value { font-size: 30px; font-weight: 900; margin-top: 8px; }
.metric .label { color: var(--muted); font-size: 14px; }
.metric .desc { color: var(--muted); font-size: 12px; margin-top: 8px; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.panel {
  background: var(--card);
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 12px 30px rgba(74, 61, 47, 0.06);
}
.panel.wide { grid-column: 1 / -1; }
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.panel-head h2 { margin: 0; font-size: 20px; }
.panel-head span { color: var(--muted); font-size: 13px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}
th { color: var(--muted); font-weight: 800; }
.text-cell { min-width: 260px; max-width: 460px; line-height: 1.7; }
.status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}
.status.pending { background: #fff0d8; color: var(--warning); }
.status.rejected, .status.removed, .status.expired, .status.cancelled { background: #f6e8e2; color: var(--danger); }
.status.paid, .status.active, .status.approved, .status.completed { background: var(--soft); color: var(--primary); }

.list-item {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: 0; }
.list-title { font-weight: 800; margin-bottom: 6px; }
.list-meta { color: var(--muted); font-size: 13px; line-height: 1.6; }
.empty, .loading { color: var(--muted); padding: 18px 0; }

.course-tabs,
.course-actions,
.day-tabs,
.upload-line,
.actions-cell {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.actions-cell { margin-bottom: 0; }
.day-tabs { padding: 10px 0 18px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.day-tabs button.active { background: var(--primary); color: #fff; }
.course-workspace .course-actions { align-items: center; }
.course-detail,
.media-library {
  margin-top: 22px;
}

.media-form {
  display: grid;
  grid-template-columns: 1.1fr 120px 2fr 120px 1.4fr auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}

.panel-head.sub {
  margin-top: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.day-editor {
  padding: 18px;
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffaf1;
}

.day-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.day-head span {
  color: var(--muted);
  font-size: 13px;
}

.task-editors {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.task-editor {
  padding: 14px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
}

.day-editor.readonly input,
.day-editor.readonly textarea {
  pointer-events: none;
}

.upload-line {
  align-items: center;
  margin: 8px 0 16px;
}
.upload-line input { flex: 1 1 220px; margin-top: 0; }
.upload-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.course-image-preview {
  display: block;
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 14px;
  margin: 12px 0;
  border: 1px solid var(--line);
}
.media-url {
  word-break: break-all;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  padding: 10px;
  border-radius: 12px;
  background: #f7f3ec;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv strong { text-align: right; }

@media (max-width: 980px) {
  .dashboard { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { grid-template-columns: 1fr; }
  .task-editors { grid-template-columns: 1fr; }
  .media-form { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 16px; }
}

@media (max-width: 560px) {
  .main-panel { padding: 18px; }
  .nav { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr; }
}
