:root {
  --ink: #13201a;
  --muted: #607064;
  --line: #d9e1d8;
  --paper: #f4f6f1;
  --panel: #ffffff;
  --green: #1f7a4d;
  --green-dark: #102c1f;
  --mint: #dff2e6;
  --gold: #b88421;
  --red: #b44235;
  --blue: #276a8a;
  --shadow: 0 22px 60px rgba(20, 35, 27, .12);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 8% -4%, rgba(184, 132, 33, .14), transparent 28rem),
    radial-gradient(circle at 88% 12%, rgba(39, 106, 138, .10), transparent 24rem),
    repeating-linear-gradient(135deg, rgba(19, 32, 26, .025), rgba(19, 32, 26, .025) 1px, transparent 1px, transparent 9px),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; }
button {
  min-height: 40px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
  padding: 9px 13px;
  cursor: pointer;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s var(--ease), background .18s var(--ease);
}
button:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(20, 35, 27, .10); }
button.primary { background: var(--green); color: white; border-color: var(--green); font-weight: 700; }
button.ghost { background: transparent; }
button.download { border-color: #c4d7cb; background: #f7fbf8; font-weight: 700; }
button.danger { border-color: #efc6c0; background: #fff7f6; color: #b44235; font-weight: 700; }
button:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(31, 122, 77, .22);
  outline-offset: 2px;
}
a { color: var(--green); text-decoration: none; }

.skip-nav {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 40;
  background: var(--green-dark);
  color: #fff;
  padding: 8px 12px;
  border-radius: 7px;
  transform: translateY(-160%);
}
.skip-nav:focus { transform: translateY(0); }

.shell { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, rgba(255,255,255,.06), transparent 28%), var(--green-dark);
  color: white;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.mark {
  width: 44px;
  height: 44px;
  border-radius: 7px;
  background: #e9c46a;
  color: #102018;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0;
}
.brand h1 { font-size: 18px; margin: 0; line-height: 1.1; }
.brand p { margin: 4px 0 0; color: #bdd0c5; font-size: 12px; }
.nav button {
  width: 100%;
  text-align: left;
  color: #e8f3ed;
  border-color: transparent;
  background: transparent;
  margin-bottom: 6px;
  font-weight: 700;
}
.nav button.active { background: rgba(255,255,255,.13); border-color: rgba(255,255,255,.14); }
.userbox p, .side-note { color: #bdd0c5; margin: 6px 0 0; font-size: 13px; line-height: 1.45; }
.side-note { border-top: 1px solid rgba(255,255,255,.16); padding-top: 14px; margin-top: auto; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.login-card { width: min(520px, 100%); padding: 28px; }
.login-card h1 { margin: 0 0 8px; font-size: 28px; }
.login-card p { color: var(--muted); margin: 0 0 20px; }

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  min-width: 0;
}
.field label { font-size: 13px; color: var(--muted); font-weight: 700; }
.field input, .field select, .field textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  background: white;
}
.field small {
  color: var(--muted);
  display: block;
  min-width: 0;
  line-height: 1.45;
}

.date-preview {
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #cfe3d5;
  background: #f5faf6;
  color: var(--green);
  font-weight: 700;
  line-height: 1.35;
  border-radius: 8px;
}

.content { padding: 24px clamp(18px, 3vw, 34px) 42px; min-width: 0; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.kicker {
  color: var(--gold);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 800;
  margin: 0 0 7px;
}
.topbar h2 { margin: 0; font-size: clamp(24px, 3vw, 34px); letter-spacing: 0; }
.topbar p { margin: 5px 0 0; color: var(--muted); }
.live-sync {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 5px 8px;
  border: 1px solid #cfe3d5;
  border-radius: 999px;
  background: #f5faf6;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}
.live-sync::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(31, 122, 77, .12);
}
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar input, .toolbar select { border: 1px solid var(--line); border-radius: 7px; padding: 9px 10px; background: white; }

.tabs {
  display: inline-flex;
  gap: 4px;
  background: rgba(255,255,255,.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 10px 28px rgba(20, 35, 27, .08);
}
.tabs button {
  min-width: 118px;
  border-color: transparent;
  background: transparent;
  font-weight: 800;
}
.tabs button.active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
  box-shadow: none;
}

.summary-layout,
.document-workspace {
  display: grid;
  gap: 12px;
}
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  background: rgba(255,255,255,.7);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.section-head h3 {
  margin: 0;
  font-size: 20px;
}
.section-head p {
  margin: 5px 0 0;
  color: var(--muted);
  max-width: 68ch;
}

.filterbar, .actionbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.filterbar { justify-content: flex-start; flex-wrap: wrap; }
.filterbar input, .filterbar select {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: white;
}
.filterbar input { min-width: min(360px, 100%); flex: 1; }
.actionbar {
  position: sticky;
  top: 10px;
  z-index: 6;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(12px);
  border: 1px solid #d5e5d8;
  border-radius: 8px;
  padding: 10px 12px;
}

.stats { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 12px; margin-bottom: 12px; }
.stat { padding: 16px; background: white; border: 1px solid var(--line); border-radius: 8px; }
.stat span { color: var(--muted); font-size: 13px; }
.stat strong { display: block; font-size: 28px; margin-top: 4px; }
.stat.warn { border-color: #ead6a5; background: #fffaf0; }
.stat.danger { border-color: #efc6c0; background: #fff7f6; }

.progress-rail {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 16px;
}
.rail-segment {
  background: rgba(255,255,255,.78);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}
.rail-segment span { color: var(--muted); display: block; font-size: 12px; min-height: 32px; }
.rail-segment strong {
  display: block;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 20px;
  margin-top: 4px;
}

.generated-panel {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: #f5faf6;
  border: 1px solid #cfe3d5;
  border-left: 5px solid var(--green);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.generated-panel p { margin: 4px 0 0; color: var(--muted); }

.panel { padding: 0; overflow: hidden; }
.dosen-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 16px; }
.dosen-card { text-align: left; padding: 12px; background: white; border: 1px solid var(--line); }
.dosen-card:hover { border-color: rgba(31, 122, 77, .42); }
.dosen-card span { display: block; font-size: 13px; min-height: 38px; }
.dosen-card strong { display: block; margin: 6px 0; font-size: 20px; }
.dosen-card small { color: var(--muted); display: block; }
.dosen-card .mini { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; min-height: auto; }
.meter { height: 6px; background: #e8eee9; border-radius: 999px; overflow: hidden; margin-bottom: 7px; }
.meter i { display: block; height: 100%; background: var(--green); }

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}
th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}
th {
  font-size: 11px;
  color: var(--muted);
  background: #fbfcfa;
  position: sticky;
  top: 0;
  z-index: 1;
}
td { font-size: 12px; line-height: 1.35; }
tbody tr:hover { background: #fbfdf9; }
th:nth-child(1) { width: 6%; }
th:nth-child(2) { width: 31%; }
th:nth-child(3) { width: 14%; }
th:nth-child(4) { width: 10%; }
th:nth-child(5) { width: 17%; }
th:nth-child(6) { width: 15%; }
th:nth-child(7) { width: 7%; }
.table-wrap {
  max-height: calc(100vh - 330px);
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 320px;
}

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 7px; font-size: 11px; border: 1px solid var(--line); background: #fff; }
.badge.mou { color: var(--blue); }
.badge.pks { color: var(--gold); }
.badge.generated { color: var(--green); margin-top: 5px; border-color: #cfe3d5; background: #f5faf6; }
.fileline, .muted { color: var(--muted); font-size: 11px; }
.status {
  width: 100%;
  min-width: 0;
  margin-top: 5px;
}
.status-pill {
  display: inline-flex;
  margin-bottom: 6px;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  border: 1px solid var(--line);
}
.status-pill.neutral, .status-pill.muted { background: #f5f6f4; color: #58645e; }
.status-pill.info { background: #e7f2f7; color: #276a8a; }
.status-pill.warn { background: #fff5dc; color: #8a5d12; }
.status-pill.ready, .status-pill.done { background: #e6f4ea; color: #1f7a4d; }
.status-pill.danger { background: #fdecea; color: #b44235; }
.note {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  resize: vertical;
}
.actions {
  display: grid;
  gap: 6px;
}
.actions a { display: block; }
.actions button {
  width: 100%;
  min-height: 32px;
  padding: 6px 8px;
  font-size: 11px;
  line-height: 1.1;
}

.drawer {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 14, .42);
  display: none;
  align-items: stretch;
  justify-content: flex-end;
  z-index: 10;
}
.drawer.open { display: flex; }
.drawer-panel {
  width: min(720px, 100%);
  background: white;
  padding: 26px;
  overflow: auto;
  box-shadow: -18px 0 52px rgba(15, 25, 19, .18);
}
.drawer-panel h3 { margin: 0 0 16px; font-size: 24px; }
.drawer-copy { color: var(--muted); margin-top: -6px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-section {
  margin: 8px 0 -2px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--green);
}
.reference-card {
  display: block;
  width: 100%;
  margin-top: 4px;
  border: 1px solid #d5e5d8;
  border-radius: 8px;
  background: #f5faf6;
  padding: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.reference-card b { color: var(--ink); display: block; margin-bottom: 4px; }
.reference-card a { font-weight: 800; }
.warning-text { color: var(--gold) !important; }
.empty { padding: 36px; text-align: center; color: var(--muted); }
.error { color: var(--red); margin-top: 10px; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  background: var(--green-dark);
  color: white;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,.2);
  max-width: min(520px, calc(100vw - 36px));
}
.toast a { color: #b7f0cd; margin-left: 10px; font-weight: 700; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .progress-rail { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .stats, .progress-rail { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .topbar { display: block; }
  .tabs { margin-top: 14px; width: 100%; }
  .tabs button { flex: 1; min-width: 0; }
  .section-head { display: block; }
  .section-head .toolbar { margin-top: 12px; }
  .toolbar { margin-top: 14px; }
  .filterbar, .actionbar, .generated-panel { display: block; }
  .actionbar { position: static; }
  .actionbar .toolbar, .generated-panel .toolbar { margin-top: 10px; }
  .form-grid { grid-template-columns: 1fr; }
  .table-wrap { max-height: none; overflow: visible; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
  td { border-bottom: 0; padding: 8px 14px; }
  td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    margin-bottom: 4px;
    text-transform: uppercase;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
