/* ============================================================
   MEREKAH — Client Portal
   Mewarisi palet & tipografi landing page (cream + terakota + daun)
   ============================================================ */

:root {
  --paper:      #FBF7F0;
  --paper-soft: #F3EADB;
  --paper-card: #FFFDFA;
  --ink:        #221A12;
  --ink-2:      #3A2F23;
  --muted:      #6E6151;
  --line:       #E7DCC9;

  --brand:      #E2703A;
  --brand-deep: #C2541F;
  --leaf:       #1C5A45;
  --leaf-deep:  #103D2E;
  --gold:       #EBA417;
  --danger:     #CC3B3B;

  --dark:       #16120C;

  --f-sans:    'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --f-display: 'Fraunces', Georgia, 'Times New Roman', serif;

  --r-sm: 12px;
  --r:    18px;
  --r-lg: 26px;
  --pill: 999px;

  --shadow-sm: 0 2px 8px -3px rgba(34,26,18,.18);
  --shadow:    0 18px 40px -22px rgba(34,26,18,.40);
  --container: 1200px;
  --ease: cubic-bezier(.22,.61,.36,1);
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--f-sans);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
ul { list-style: none; }
svg.lucide { stroke-width: 1.9; }
.ic { width: 1.05em; height: 1.05em; vertical-align: -0.18em; flex: none; }
::selection { background: var(--brand); color: #fff; }
:focus-visible { outline: 2.5px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ---------- Brand mark ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; }
.brand__name { font-size: 1.15rem; letter-spacing: -.02em; }

/* ---------- Tombol ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: var(--pill);
  font-weight: 700; font-size: .94rem;
  transition: transform .2s var(--ease), background .2s, box-shadow .2s, border-color .2s;
}
.btn--sm { padding: 8px 15px; font-size: .85rem; }
.btn--block { width: 100%; }
.btn--primary { background: var(--brand); color: #fff; box-shadow: 0 12px 26px -12px rgba(226,112,58,.7); }
.btn--primary:hover { background: var(--brand-deep); transform: translateY(-2px); }
.btn--leaf { background: var(--leaf); color: #fff; }
.btn--leaf:hover { background: var(--leaf-deep); transform: translateY(-2px); }
.btn--ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn--ghost:hover { border-color: var(--ink); }
.btn--danger { background: transparent; color: var(--danger); border: 1.5px solid rgba(204,59,59,.4); }
.btn--danger:hover { background: rgba(204,59,59,.08); border-color: var(--danger); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ---------- Form ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: .85rem; font-weight: 700; color: var(--ink-2); }
.field input, .field select, .field textarea {
  font: inherit; font-size: .95rem;
  padding: 11px 14px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  width: 100%;
}
.field textarea { resize: vertical; min-height: 80px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(226,112,58,.14);
}
.field--row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ============================================================
   HALAMAN LOGIN
   ============================================================ */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1100px 500px at 110% -10%, rgba(226,112,58,.14), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(28,90,69,.12), transparent 55%),
    var(--paper);
}
.login__card {
  width: 100%; max-width: 420px; background: var(--paper-card);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow); padding: clamp(28px, 5vw, 40px);
}
.login__back {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .86rem; font-weight: 600; color: var(--muted);
  margin-bottom: 16px; transition: color .18s ease, gap .18s ease;
}
.login__back:hover { color: var(--brand-deep); gap: 9px; }
.login__head { text-align: center; margin-bottom: 26px; }
.login__head .brand { justify-content: center; margin-bottom: 18px; }
.login__title { font-family: var(--f-display); font-size: 1.7rem; line-height: 1.15; margin-bottom: 6px; }
.login__sub { color: var(--muted); font-size: .94rem; }
.login__foot { text-align: center; margin-top: 20px; font-size: .88rem; color: var(--muted); }
.login__foot a { color: var(--brand-deep); font-weight: 600; }

.alert {
  border-radius: var(--r-sm); padding: 11px 14px; font-size: .9rem;
  margin-bottom: 16px; display: flex; gap: 9px; align-items: flex-start;
}
.alert--error { background: rgba(204,59,59,.1); color: #9c2a2a; border: 1px solid rgba(204,59,59,.25); }
.alert--info  { background: rgba(235,164,23,.12); color: #8a5e00; border: 1px solid rgba(235,164,23,.3); }
.alert--ok    { background: rgba(28,90,69,.1); color: var(--leaf-deep); border: 1px solid rgba(28,90,69,.25); }

/* ============================================================
   DASHBOARD — shell (rail kiri desktop / bottom-bar mobile + app-bar)
   ============================================================ */
.shell { display: flex; min-height: 100vh; }

/* ---- Rail (kolom navigasi kiri di desktop) ---- */
.rail {
  width: 256px; flex: none; position: sticky; top: 0; align-self: flex-start;
  height: 100vh; display: flex; flex-direction: column;
  background: var(--paper-card); border-right: 1px solid var(--line);
}
.rail__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; min-height: 62px;     /* samakan tinggi dengan .appbar → garis bawah sejajar */
  border-bottom: 1px solid var(--line);
}
.rail__nav { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 3px; }

/* Profil di bawah sidebar (desktop) */
.rail__foot { padding: 12px; border-top: 1px solid var(--line); }
.rail__foot .profile { width: 100%; }
.rail__foot .profile__btn { width: 100%; justify-content: flex-start; }
.rail__foot .profile__name { flex: 1; }
.rail__foot .profile__chev { margin-left: auto; }
/* dropdown membuka ke ATAS karena profil ada di bawah */
.rail__foot .profile__menu { top: auto; bottom: calc(100% + 8px); left: 0; right: 0; width: auto; }

.navitem {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 13px; border-radius: 11px; font-weight: 600; font-size: .94rem; color: var(--ink-2);
  transition: background .15s, color .15s;
}
.navitem:hover { background: var(--paper-soft); color: var(--ink); }
.navitem.is-active { background: rgba(226,112,58,.12); color: var(--brand-deep); }
.navitem.is-active .ic { color: var(--brand); }
.navitem .ic { width: 1.2em; height: 1.2em; color: var(--muted); transition: color .15s; }
.navitem__badge {
  margin-left: auto; min-width: 20px; text-align: center; background: var(--brand); color: #fff;
  font-size: .72rem; font-weight: 800; padding: 1px 7px; border-radius: var(--pill);
}
.navitem.is-active .navitem__badge { background: var(--brand-deep); }

/* ---- Main column ---- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.appbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 14px;
  padding: 12px 28px; min-height: 62px;
  background: rgba(251,247,240,.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.appbar__title { font-family: var(--f-display); font-size: 1.2rem; font-weight: 600; }
.appbar__spacer { flex: 1; }

.avatar {
  width: 36px; height: 36px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--leaf); color: #fff; font-weight: 800; font-size: .98rem; font-family: var(--f-display);
}

/* ---- Menu profil (klik avatar → dropdown berisi Keluar) ---- */
.profile { position: relative; }
.profile__btn {
  display: flex; align-items: center; gap: 9px; padding: 5px 8px 5px 5px;
  border-radius: var(--pill); border: 1px solid var(--line); background: var(--paper-card);
  transition: background .15s, border-color .15s;
}
.profile__btn:hover { background: var(--paper-soft); }
.profile__name { font-weight: 700; font-size: .9rem; max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile__chev { width: 1em; height: 1em; color: var(--muted); }
.profile__btn[aria-expanded="true"] .profile__chev { transform: rotate(180deg); }

.profile__menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; width: 240px;
  background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 8px; animation: pop .14s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.profile__head { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.profile__item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: 10px; font-weight: 600; font-size: .92rem; color: var(--ink-2);
}
.profile__item:hover { background: rgba(204,59,59,.08); color: var(--danger); }
.profile__item .ic { width: 1.15em; height: 1.15em; }

.topbar__role {
  display: inline-block; margin-top: 8px; font-size: .68rem; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase; padding: 2px 9px; border-radius: var(--pill);
}
.topbar__role--admin  { background: var(--leaf); color: #fff; }
.topbar__role--client { background: rgba(226,112,58,.14); color: var(--brand-deep); }
.topbar__user { line-height: 1.3; min-width: 0; }
.topbar__user b { font-size: .92rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__user span { display: block; font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.view { padding: 30px 28px 80px; max-width: 1180px; width: 100%; }

.page-head { margin-bottom: 24px; }
.page-head h1 { font-family: var(--f-display); font-size: clamp(1.6rem, 3.5vw, 2.1rem); line-height: 1.1; }
.page-head p { color: var(--muted); margin-top: 6px; }
/* offset agar judul section tak ketutup app-bar saat di-scroll dari menu */
[id^="sec-"], #accHistorySection { scroll-margin-top: 80px; }

/* ---------- Kartu statistik ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 30px; }
.stat {
  background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.stat__top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); }
.stat__top span { font-size: .82rem; font-weight: 700; }
.stat__icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.stat__num { font-family: var(--f-display); font-size: 2rem; line-height: 1; margin-top: 12px; }
.tone-gold  .stat__icon, .tone-gold.stat__icon   { background: rgba(235,164,23,.16); color: var(--gold); }
.tone-brand .stat__icon, .tone-brand.stat__icon  { background: rgba(226,112,58,.14); color: var(--brand-deep); }
.tone-leaf  .stat__icon, .tone-leaf.stat__icon   { background: rgba(28,90,69,.13); color: var(--leaf); }
.tone-muted .stat__icon, .tone-muted.stat__icon  { background: var(--paper-soft); color: var(--muted); }

/* ---------- Pipeline (kolom kanban) ---------- */
.pipeline { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.col {
  background: var(--paper-soft); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px; min-height: 120px;
}
.col__head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-weight: 800; font-size: .9rem; }
.col__count { margin-left: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--pill); padding: 1px 9px; font-size: .78rem; }
.col__empty { color: var(--muted); font-size: .85rem; padding: 10px 4px; }

/* ---------- Kartu project ---------- */
.pcard {
  background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow-sm);
  transition: transform .18s var(--ease), box-shadow .18s, border-color .18s;
}
.pcard:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: rgba(226,112,58,.4); }
.pcard__name { font-weight: 700; font-size: .98rem; line-height: 1.3; }
.pcard__svc { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.pcard__meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; font-size: .8rem; color: var(--muted); }
.pcard__meta span { display: inline-flex; align-items: center; gap: 4px; }

.bar { height: 7px; border-radius: var(--pill); background: var(--paper-soft); overflow: hidden; margin-top: 10px; }
.bar__fill { height: 100%; background: linear-gradient(90deg, var(--brand), var(--gold)); border-radius: var(--pill); }

/* ---------- Badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .74rem; font-weight: 800; padding: 3px 10px; border-radius: var(--pill);
}
.badge.tone-gold   { background: rgba(235,164,23,.16); color: #8a5e00; }
.badge.tone-brand  { background: rgba(226,112,58,.14); color: var(--brand-deep); }
.badge.tone-leaf   { background: rgba(28,90,69,.13); color: var(--leaf); }
.badge.tone-muted  { background: var(--paper-soft); color: var(--muted); }
.badge.tone-danger { background: rgba(204,59,59,.12); color: #9c2a2a; }

/* ---------- Kartu approval ---------- */
.acc {
  background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px 20px; margin-bottom: 14px; box-shadow: var(--shadow-sm);
}
.acc__top { display: flex; align-items: flex-start; gap: 12px; }
.acc__title { font-weight: 700; font-size: 1.02rem; }
.acc__sub { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.acc__desc { margin: 12px 0; font-size: .92rem; color: var(--ink-2); }
.acc__actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.acc__note { margin-top: 12px; }
.acc__note textarea { min-height: 60px; }
.acc__decided { font-size: .82rem; color: var(--muted); margin-top: 8px; }
.acc--done { background: var(--paper-soft); box-shadow: none; padding: 14px 18px; }
.acc--done .acc__title { font-size: .95rem; }
.acc--done .acc__desc { margin: 8px 0 0; font-size: .88rem; font-style: italic; }

/* ---------- Report ---------- */
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.metric {
  background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 18px;
}
.metric__label { font-size: .8rem; color: var(--muted); font-weight: 700; display: flex; align-items: center; gap: 6px; }
.metric__value { font-family: var(--f-display); font-size: 1.7rem; margin-top: 8px; line-height: 1; }
.metric__sub { font-size: .76rem; color: var(--muted); margin-top: 4px; }
.metric--hi .metric__value { color: var(--leaf); }

/* ---------- Tabel admin ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--paper-card); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 640px; }
.tbl th, .tbl td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.tbl th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--paper-soft); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: rgba(243,234,219,.4); }
.tbl__actions { display: flex; gap: 6px; }
.iconbtn { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; border: 1px solid var(--line); color: var(--muted); }
.iconbtn:hover { border-color: var(--brand); color: var(--brand-deep); }
.iconbtn--danger:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- Section & panel ---------- */
.section { margin-bottom: 38px; }
.section__head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.section__head h2 { font-family: var(--f-display); font-size: 1.4rem; }
.section__head .btn { margin-left: auto; }
.panel { background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; }

.empty {
  text-align: center; color: var(--muted); padding: 40px 20px;
  border: 1.5px dashed var(--line); border-radius: var(--r); background: var(--paper-soft);
}
.empty .ic { width: 30px; height: 30px; margin-bottom: 10px; color: var(--brand); opacity: .7; }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 100; background: rgba(34,26,18,.45);
  display: none; place-items: center; padding: 24px; backdrop-filter: blur(3px);
}
.modal-back.is-open { display: grid; }
.modal {
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  background: var(--paper-card); border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 26px;
}
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal__head h3 { font-family: var(--f-display); font-size: 1.4rem; }
.modal__foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* ---------- Loader ---------- */
.loading { text-align: center; padding: 60px 20px; color: var(--muted); }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Selector klien (admin) ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 22px; }
.toolbar .field { margin-bottom: 0; }
.toolbar select { min-width: 220px; }

[hidden] { display: none !important; }

/* ---------- Responsif ---------- */
@media (max-width: 980px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .pipeline { grid-template-columns: 1fr 1fr; }
}

/* Rail → bottom-bar di layar kecil */
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .rail {
    order: 2; width: 100%; height: auto;
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 80;
    flex-direction: row; border-right: none; border-top: 1px solid var(--line);
    box-shadow: 0 -6px 20px -12px rgba(34,26,18,.35);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .rail__brand { display: none; }                  /* brand pindah ke app-bar */
  .rail__nav {
    flex: 1; min-width: 0; flex-direction: row; padding: 6px 4px; gap: 0;
    overflow-x: auto; justify-content: space-around; width: auto;
  }
  /* Profil jadi item TERAKHIR di bottom-bar (gaya tab "Akun") */
  .rail__foot { padding: 0; border-top: none; border-left: 1px solid var(--line); display: flex; align-items: stretch; }
  .rail__foot .profile { display: flex; }
  .rail__foot .profile__btn {
    flex-direction: column; gap: 3px; border: none; border-radius: 10px;
    background: transparent; padding: 7px 14px;
  }
  .rail__foot .profile__btn::after { content: "Akun"; font-size: .68rem; font-weight: 700; color: var(--ink-2); }
  .rail__foot .profile__chev { display: none; }
  .rail__foot .profile__menu { top: auto; bottom: calc(100% + 8px); right: 6px; left: auto; width: 240px; }
  /* item navigasi: ikon di atas, label kecil di bawah */
  .navitem {
    position: relative; flex-direction: column; gap: 3px; flex: 1 1 0; min-width: 0;
    padding: 7px 4px; border-radius: 10px; text-align: center;
    font-size: .68rem; font-weight: 700;
  }
  .navitem span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .navitem .ic { width: 1.45em; height: 1.45em; }
  .navitem.is-active { background: transparent; }  /* cukup warna ikon+teks */
  /* badge → titik kecil di pojok ikon */
  .navitem__badge {
    position: absolute; margin: 0; top: 2px; left: 50%;
    min-width: 16px; height: 16px; line-height: 15px;
    transform: translateX(4px); font-size: .62rem; padding: 0 4px;
  }

  .appbar { padding: 10px 16px; }
  .view { padding: 22px 16px calc(78px + env(safe-area-inset-bottom, 0px)); }
  .profile__name { display: none; }                /* hemat ruang: cukup avatar */
}

@media (max-width: 560px) {
  .stats, .pipeline { grid-template-columns: 1fr; }
  .field--row { grid-template-columns: 1fr; }
}
