:root {
  --brand-900: #3D2712; --brand-800: #543619; --brand-700: #6E4621; --brand-600: #8A5A2B;
  --brand-100: #F3E9DC; --brand-50: #FBF7F2;
  --gold-400: #FBBF24; --gold-300: #FCD34D; --gold-100: #FEF3C7;
  --cream: #FDFBF7;
  --ok: #15803D; --okbg: #DCFCE7; --err: #B91C1C; --errbg: #FEE2E2;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: var(--cream); color: var(--brand-900); font-size: 14.5px; line-height: 1.5;
}
a { color: var(--brand-700); text-decoration: none; }
a:hover { color: var(--brand-900); }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
.muted { color: #8a7560; font-size: .85rem; margin: .25rem 0 0; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }

/* ---- Layout ---- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex-shrink: 0; background: var(--brand-900); color: #f5ede1;
  padding: 1.25rem 1rem; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .65rem; padding: 0 .25rem 1rem; }
.brand strong { display: block; font-size: .95rem; }
.brand small { color: var(--gold-300); font-size: .72rem; }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; font-weight: 800;
  background: linear-gradient(135deg, var(--gold-400), var(--brand-600)); color: #fff; font-size: 1.3rem;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  color: #e7d9c6; padding: .55rem .7rem; border-radius: 9px; font-size: .9rem; transition: .15s;
}
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.is-active { background: var(--gold-400); color: var(--brand-900); font-weight: 600; }
.nav-label {
  margin: 1rem .25rem .35rem; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: #b89a7a;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1.5rem; background: #fff; border-bottom: 1px solid var(--brand-100);
}
.topbar-user { display: flex; align-items: center; gap: 1rem; font-size: .9rem; }
.content { padding: 1.5rem; max-width: 1100px; width: 100%; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}

/* ---- Panels ---- */
.panel { background: #fff; border: 1px solid var(--brand-100); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.panel.no-pad { padding: 0; overflow: hidden; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat-card {
  display: flex; flex-direction: column; gap: .25rem; padding: 1.1rem; border-radius: var(--radius);
  background: #fff; border: 1px solid var(--brand-100); transition: .18s;
}
.stat-card:hover { border-color: var(--gold-300); transform: translateY(-2px); box-shadow: 0 8px 20px -10px rgba(84,54,25,.3); }
.stat-num { font-size: 1.9rem; font-weight: 800; color: var(--brand-700); }
.stat-label { font-size: .82rem; color: #8a7560; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.chip { background: var(--gold-100); color: var(--brand-800); padding: .4rem .8rem; border-radius: 999px; font-size: .82rem; }
.chip:hover { background: var(--gold-300); }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--brand-100); vertical-align: middle; }
.table thead th { background: var(--brand-50); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: #8a7560; }
.table tbody tr:hover { background: var(--brand-50); }
.ta-right { text-align: right; }
.empty { text-align: center; color: #8a7560; padding: 1.5rem; }
.actions { display: flex; gap: .4rem; justify-content: flex-end; align-items: center; }
.actions form { margin: 0; }
.badge { padding: .15rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 600; }
.badge-on { background: var(--okbg); color: var(--ok); }
.badge-off { background: #f1eadf; color: #8a7560; }

/* ---- Kritik & Saran ---- */
.nav-badge { display: inline-block; margin-left: .35rem; padding: .05rem .45rem; border-radius: 999px; background: var(--err); color: #fff; font-size: .68rem; font-weight: 700; vertical-align: middle; }
.row-unread { background: #fffaf0; }
.pesan { white-space: pre-line; max-width: 34rem; line-height: 1.5; }

/* ---- Forms ---- */
.form .field { margin-bottom: 1.1rem; }
.field-label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .88rem; }
.req { color: var(--err); }
input[type=text], input[type=password], input[type=number], input[type=date], textarea, select {
  width: 100%; padding: .6rem .7rem; border: 1px solid #ddccb6;
  border-radius: 9px; font-size: .9rem; font-family: inherit; background: #fff; color: var(--brand-900);
}
input:focus, textarea:focus { outline: none; border-color: var(--gold-400); box-shadow: 0 0 0 3px rgba(251,191,36,.25); }
textarea { resize: vertical; }
.json-editor { min-height: 360px; font-size: .85rem; line-height: 1.6; }
.hint { display: block; color: #9a8569; font-size: .76rem; margin-top: .3rem; }
.check { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; font-weight: 500; }
.check-inline { margin-right: .25rem; }
.check input { width: auto; }
.days { display: flex; flex-wrap: wrap; gap: .5rem .9rem; }
.form-actions { display: flex; gap: .6rem; margin-top: .5rem; }

/* ---- Form ramah (schema) ---- */
.sgroup {
  border: 1px solid var(--brand-100); border-radius: var(--radius);
  padding: 1rem 1.1rem .4rem; margin: 0 0 1.1rem; background: var(--brand-50);
}
.sgroup > legend {
  padding: .15rem .6rem; font-weight: 700; font-size: .82rem; color: var(--brand-700);
  background: var(--gold-100); border-radius: 999px;
}
.sgroup .sgroup { background: #fff; }

.rep { display: flex; flex-direction: column; gap: .6rem; margin-top: .4rem; }
.rep-item {
  position: relative; border: 1px dashed #d9c7ad; border-radius: 10px;
  padding: .9rem .9rem .3rem; background: #fff;
}
.rep-item .rep-remove { position: absolute; top: .55rem; right: .55rem; }
.rep-item .field:last-of-type { margin-bottom: .6rem; }
.rep-scalar { display: flex; align-items: center; gap: .5rem; padding: .4rem; }
.rep-scalar input { flex: 1; }
.rep-scalar .rep-remove { position: static; }
.rep-add { align-self: flex-start; }

/* ---- Icon uploader ---- */
.icon-preview img { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; border: 1px solid var(--brand-100); background: var(--brand-50); padding: 4px; }

/* ---- Schedules builder ---- */
.schedules-builder { counter-reset: slot-no; }
.schedules-builder [data-item] { counter-increment: slot-no; }
.schedules-builder [data-item]::before {
  content: "Jadwal ke-" counter(slot-no);
  display: block; font-weight: 700; font-size: .82rem;
  color: var(--brand-700); margin-bottom: .65rem;
}

/* ---- Uploader ---- */
.uploader .up-row { display: flex; align-items: center; gap: .6rem; margin-top: .5rem; }
.up-status { font-size: .8rem; color: #8a7560; }
.up-preview { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.up-preview img { width: 84px; height: 84px; object-fit: cover; border-radius: 9px; border: 1px solid var(--brand-100); background: #fff; }
.up-filelink { display: inline-flex; align-items: center; gap: .3rem; padding: .35rem .6rem; background: var(--brand-50); border-radius: 8px; font-size: .8rem; }

/* ---- Media grid ---- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.media-item { background: #fff; border: 1px solid var(--brand-100); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.media-thumb { aspect-ratio: 4 / 3; background: var(--brand-50); display: grid; place-items: center; overflow: hidden; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-file { font-weight: 800; color: var(--brand-600); letter-spacing: .06em; }
.media-body { padding: .6rem; display: flex; flex-direction: column; gap: .5rem; }
.copy-src { font-size: .72rem; padding: .35rem .5rem; }
.media-actions { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.media-actions form { margin: 0; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem; padding: .55rem .95rem; border-radius: 9px;
  font-size: .87rem; font-weight: 600; border: 1px solid transparent; cursor: pointer; transition: .15s; font-family: inherit;
}
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-primary { background: var(--gold-400); color: var(--brand-900); }
.btn-primary:hover { background: var(--gold-300); }
.btn-ghost { background: transparent; border-color: var(--brand-100); color: var(--brand-700); }
.btn-ghost:hover { background: var(--brand-50); }
.btn-danger { background: var(--errbg); color: var(--err); }
.btn-danger:hover { background: #fbcfcf; }

/* ---- Alerts ---- */
.alert { padding: .7rem 1rem; border-radius: 9px; margin-bottom: 1.1rem; font-size: .88rem; }
.alert-success { background: var(--okbg); color: var(--ok); }
.alert-error { background: var(--errbg); color: var(--err); }

/* ---- Login ---- */
.login-page { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(135deg, var(--brand-800), var(--brand-900)); }
.login-card {
  background: #fff; padding: 2rem; border-radius: 18px; width: min(360px, 92vw);
  box-shadow: 0 25px 60px -20px rgba(0,0,0,.5); text-align: center;
}
.login-card h1 { font-size: 1.3rem; margin-top: .5rem; }
.login-card label { display: block; text-align: left; font-weight: 600; font-size: .85rem; margin: .9rem 0 .35rem; }
.login-brand { display: flex; justify-content: center; }
.login-brand .brand-mark { width: 52px; height: 52px; font-size: 1.7rem; }
.login-card .btn { margin-top: 1.2rem; }

/* ---- Responsif ---- */
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .nav { flex-flow: row wrap; }
  .nav-label { width: 100%; }
}
