:root {
  --blue: #4DA9E6; --yellow: #F1B740; --navy: #1D45C4;
  --ink: #0F172A; --muted: #5B6B82; --line: #E2E8F0; --bg: #F6F9FC; --card: #FFFFFF;
  --green: #1E9E5A; --red: #C0392B;
  --radius: 13px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 14px rgba(15,23,42,.05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
a { color: var(--navy); }

/* header */
.topbar { background: #fff; border-bottom: 3px solid var(--blue); position: sticky; top: 0; z-index: 10; }
.topbar-in { max-width: 1280px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.brand { font-size: 20px; font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.brand b { color: var(--yellow); }
.spacer { flex: 1; }

/* layout */
.wrap { max-width: 1280px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h2 { font-size: 17px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* buttons & fields */
button, .btn { font: inherit; cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 10px; padding: 8px 14px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; line-height: 1.2; }
button:hover, .btn:hover { border-color: var(--blue); }
button:disabled { opacity: .55; cursor: not-allowed; }
.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.primary:hover { background: #3a97d4; border-color: #3a97d4; }
.accent { background: var(--yellow); border-color: var(--yellow); color: #3b2a00; font-weight: 700; }
.accent:hover { background: #e3a82a; border-color: #e3a82a; }
.danger { color: var(--red); }
.danger:hover { border-color: var(--red); }
.link { border: 0; background: none; padding: 2px 6px; color: var(--navy); }
.link.danger { color: var(--red); }
:focus-visible { outline: 3px solid rgba(77,169,230,.55); outline-offset: 2px; }
input, textarea, select { font: inherit; color: inherit; width: 100%; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; }
input:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(77,169,230,.25); }
textarea { resize: vertical; min-height: 64px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 3px; }
.err { color: var(--red); font-size: 14px; min-height: 1.3em; margin: 8px 0 0; }

/* login */
.login-box { max-width: 380px; margin: 12vh auto 0; }
.login-box h1 { font-size: 24px; margin-bottom: 4px; }
.login-box .brand { font-size: 26px; }

/* dashboard */
.periodbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.periodbar input { width: auto; min-width: 170px; }
.periodbar .range { margin-left: 4px; }
.main-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.cats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.cat { border-top: 4px solid var(--blue); display: flex; flex-direction: column; gap: 10px; }
.cat[data-cat="ongoing"] { border-top-color: var(--yellow); }
.cat[data-cat="todo"] { border-top-color: var(--navy); }
.cat-head { display: flex; justify-content: space-between; align-items: baseline; }
.badge-n { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 0 9px; font-size: 12px; color: var(--muted); }
.entry-form { display: grid; gap: 6px; }
.entry-form label { margin: 4px 0 0; }
.entry-form .actions { display: flex; gap: 8px; margin-top: 8px; }
.entries { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.entry { border: 1px solid var(--line); border-radius: 11px; padding: 9px 10px; display: grid; grid-template-columns: auto 1fr; gap: 4px 9px; background: #fff; }
.entry input[type=checkbox] { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--blue); }
.entry .t { font-weight: 600; word-break: break-word; }
.entry .d { font-size: 12.5px; color: var(--muted); }
.entry .txt { font-size: 13.5px; color: #334155; margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.entry .btns { grid-column: 2; display: flex; gap: 2px; margin-top: 2px; }
.entry.editing { grid-template-columns: 1fr; }
.empty { color: var(--muted); font-size: 14px; padding: 6px 2px; }

.genbar { margin: 16px 0 0; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.genbar .big { font-size: 18px; padding: 14px 26px; border-radius: 12px; }
.spinner { width: 18px; height: 18px; border: 3px solid rgba(15,23,42,.2); border-top-color: #3b2a00; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.history { position: sticky; top: 74px; }
.history ul { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.history li { border: 1px solid var(--line); border-radius: 11px; padding: 9px 10px; }
.history li a.title { font-weight: 600; text-decoration: none; }
.history li a.title:hover { text-decoration: underline; }
.pill { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.pill.ai { background: #DDF4E7; color: #14703f; }
.pill.fb { background: #FCEFCB; color: #7a5600; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 50; max-width: 90vw; }
.toast.bad { background: var(--red); }

/* report page */
.rep-head { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 10px; }
.rep-head h1 { font-size: 21px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.dirty { color: #7a5600; font-size: 13px; }
.tabs { display: none; gap: 6px; margin-bottom: 8px; }
.tabs button[aria-selected=true] { background: var(--blue); border-color: var(--blue); color: #fff; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.pane { min-width: 0; }
#editor { width: 100%; height: calc(100vh - 220px); min-height: 420px; font: 13.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; resize: none; border-radius: var(--radius); padding: 14px; }
.preview-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); height: calc(100vh - 220px); min-height: 420px; overflow: auto; padding: 18px 12px; }

/* tipografi dokumen (preview + cetak) */
.doc { max-width: 820px; margin: 0 auto; padding: 0 14px; font-family: Calibri, "Carlito", "Segoe UI", system-ui, sans-serif; font-size: 15px; line-height: 1.6; color: var(--ink); overflow-wrap: anywhere; }
.doc h1 { font-size: 26px; color: var(--navy); margin: 0 0 12px; padding-bottom: 6px; border-bottom: 3px solid var(--blue); }
.doc h2 { font-size: 20px; color: var(--navy); margin: 26px 0 8px; padding-bottom: 3px; border-bottom: 1px solid var(--line); }
.doc h3 { font-size: 16px; color: var(--muted); margin: 18px 0 6px; }
.doc p { margin: 0 0 10px; }
.doc ul, .doc ol { margin: 0 0 10px; padding-left: 26px; }
.doc li { margin: 2px 0; }
.doc blockquote { margin: 10px 0; padding: 6px 14px; border-left: 4px solid var(--blue); background: var(--bg); color: #334155; }
.doc code { font-family: Consolas, ui-monospace, monospace; font-size: .92em; background: #EEF2F7; padding: 1px 5px; border-radius: 5px; }
.doc pre { background: #F1F5F9; padding: 10px 12px; border-radius: 8px; overflow: auto; }
.doc pre code { background: none; padding: 0; }
.doc hr { border: 0; border-top: 2px solid var(--blue); margin: 18px 0; }
.doc table { border-collapse: collapse; width: 100%; margin: 10px 0 16px; font-size: 14px; display: block; overflow-x: auto; }
.doc th { background: var(--blue); color: #fff; text-align: left; }
.doc th, .doc td { border: 1px solid #CBD5E1; padding: 6px 9px; vertical-align: top; }
.doc tr:nth-child(even) td { background: #F8FAFC; }
.doc tr { break-inside: avoid; }

@media (max-width: 980px) {
  .main-grid { grid-template-columns: 1fr; }
  .history { position: static; }
  .cats { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .tabs { display: flex; }
  .split { grid-template-columns: 1fr; }
  .split.show-ed #previewPane { display: none; }
  .split.show-pv #editorPane { display: none; }
  #editor, .preview-wrap { height: 70vh; }
  .genbar .big { width: 100%; justify-content: center; }
}

@media print {
  @page { size: A4; margin: 2cm; }
  body { background: #fff; }
  .topbar, .rep-head, .toolbar, .tabs, .toast, #editorPane, .no-print { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .split { display: block; }
  #previewPane { display: block !important; }
  .preview-wrap { border: 0; box-shadow: none; height: auto; overflow: visible; padding: 0; border-radius: 0; }
  .doc { max-width: none; padding: 0; font-size: 11pt; }
  .doc h1 { font-size: 20pt; }
  .doc h2 { font-size: 15pt; break-after: avoid; }
  .doc h3 { break-after: avoid; }
  .doc table { display: table; overflow: visible; font-size: 10pt; }
  .doc th { background: var(--blue) !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc tr:nth-child(even) td { background: #F8FAFC !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc h1, .doc h2 { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: inherit; text-decoration: none; }
}
