/* ===== Aplikasi Persuratan Digital ===== */
:root {
  --navy: #1b2c8f;
  --navy-700: #15226f;
  --navy-50: #eef1fb;
  --ink: #1f2433;
  --ink-2: #4a5165;
  --muted: #7a8196;
  --line: #e3e6ef;
  --bg: #f5f6fa;
  --card: #ffffff;
  --green: #127a4a;   --green-bg: #e6f5ec;
  --amber: #9a5b00;   --amber-bg: #fff3dc;
  --red: #b42318;     --red-bg: #fdecea;
  --gray: #5b6274;    --gray-bg: #eef0f4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 28, 60, .05), 0 1px 1px rgba(20, 28, 60, .03);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14.5px; line-height: 1.5; color: var(--ink); background: var(--bg);
}
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 700; }
small, .muted { color: var(--muted); }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--navy-700); color: #c9d0f2; padding: 20px 14px;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 20px; color: #fff; }
.brand img { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px; }
.brand b { display: block; font-size: 14px; line-height: 1.2; }
.brand span { font-size: 11.5px; color: #9ea8de; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav .sec { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #7d88c7; padding: 14px 10px 6px; }
.nav a {
  color: #d6dbf5; padding: 8px 10px; border-radius: 7px; display: flex; justify-content: space-between; align-items: center;
}
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav a.active { background: #fff; color: var(--navy-700); font-weight: 600; }
.nav .count { background: #f5b000; color: #3a2700; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 0 7px; }
.side-user { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding: 14px 8px 0; font-size: 13px; }
.side-user b { color: #fff; display: block; }
.side-user .role { color: #9ea8de; font-size: 12px; }
.side-user .links { display: flex; gap: 12px; margin-top: 8px; }
.side-user .links a, .side-user .links button { color: #c9d0f2; font-size: 12.5px; background: none; border: 0; padding: 0; cursor: pointer; font: inherit; }

.main { padding: 28px 32px 48px; max-width: 1180px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

.topbar { display: none; }

/* ---------- Komponen ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: 1.4fr 1fr; align-items: start; }

.stat { padding: 16px 18px; }
.stat .n { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 13px; }
.stat.amber .n { color: var(--amber); }
.stat.green .n { color: var(--green); }
.stat.red .n { color: var(--red); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f7f8fc; text-decoration: none; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-700); }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { background: #0d6139; }
.btn-red { color: var(--red); border-color: #f2c6c1; }
.btn-red:hover { background: var(--red-bg); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.b-menunggu { background: var(--amber-bg); color: var(--amber); }
.b-terverifikasi { background: var(--green-bg); color: var(--green); }
.b-ditolak { background: var(--red-bg); color: var(--red); }
.b-dibatalkan { background: var(--gray-bg); color: var(--gray); }
.b-off { background: var(--gray-bg); color: var(--gray); }

table.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: #fafbfd; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #fafbff; }
.tbl .nowrap { white-space: nowrap; }
.tbl-wrap { overflow-x: auto; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }

.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; border: 1px solid; }
.flash.success { background: var(--green-bg); color: var(--green); border-color: #bfe5cf; }
.flash.error { background: var(--red-bg); color: var(--red); border-color: #f5c7c2; }
.flash.info { background: var(--navy-50); color: var(--navy); border-color: #d3daf5; }

/* ---------- Form ---------- */
.form { display: grid; gap: 16px; }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.pw-box { font-family: ui-monospace, Consolas, monospace; font-size: 26px; font-weight: 700; letter-spacing: .06em; color: var(--navy-700); background: var(--navy-50); border: 1px dashed #b9c3ef; border-radius: 10px; padding: 14px 18px; text-align: center; user-select: all; }
.btn .count { background: #f5b000; color: #3a2700; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 0 7px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.label-row label { margin-bottom: 0 !important; }
.small-link { font-size: 12.5px; font-weight: 600; }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; border: 1px solid #cfd4e2; border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
.input:focus { outline: 2px solid #c3cbf3; border-color: var(--navy); }
textarea.input { min-height: 80px; resize: vertical; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.filters { display: flex; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.filters .input { width: auto; flex: 1; min-width: 180px; }
.filters select.input { flex: 0 0 190px; }
.filters .date-f { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.filters .date-f .input { min-width: 0; width: 150px; flex: none; }

/* ---------- Detail surat ---------- */
dl.info { display: grid; grid-template-columns: 160px 1fr; margin: 0; }
dl.info dt, dl.info dd { padding: 10px 0; border-bottom: 1px solid var(--line); margin: 0; }
dl.info dt { color: var(--muted); }
dl.info dd { font-weight: 500; }
dl.info > :nth-last-child(-n+2) { border-bottom: 0; }
.qr-box { text-align: center; }
.qr-box img { width: 100%; max-width: 240px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; }
.url-box { font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: #f6f7fb; border: 1px solid var(--line); border-radius: 6px; padding: 8px; word-break: break-all; text-align: left; }
.note { padding: 12px 14px; border-radius: 8px; font-size: 13.5px; }
.note.amber { background: var(--amber-bg); color: #6e4100; }
.note.red { background: var(--red-bg); color: var(--red); }
.note.green { background: var(--green-bg); color: var(--green); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0 10px 18px; border-left: 2px solid var(--line); position: relative; margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 15px; width: 10px; height: 10px; border-radius: 50%; background: var(--navy); border: 2px solid #fff; }
.timeline .t { font-size: 12px; color: var(--muted); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 500px at 50% -10%, #dfe5fb 0%, var(--bg) 60%); }
.login-card { width: 100%; max-width: 380px; padding: 30px 28px; }
.login-card .logo { width: 84px; display: block; margin: 0 auto 12px; }
.login-card h1 { text-align: center; font-size: 19px; }
.login-card p.sub { text-align: center; color: var(--muted); margin: 4px 0 22px; }

/* ---------- Responsif ---------- */
@media (max-width: 960px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .2s; z-index: 20; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(10,15,40,.35); }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--navy-700); color: #fff; position: sticky; top: 0; z-index: 10; }
  .topbar button { background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; padding: 0 4px; }
  .topbar img { width: 28px; height: 28px; background: #fff; border-radius: 6px; padding: 2px; }
  .main { padding: 18px 16px 40px; }
  .row-2 { grid-template-columns: 1fr; }
  dl.info { grid-template-columns: 1fr; }
  dl.info dt { border-bottom: 0; padding-bottom: 0; }
  .filters select.input { flex: 1; }
}

/* ---------- Draft surat ---------- */
.field .hint.err { color: var(--red); font-weight: 600; }
.draft-now { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfd; margin-bottom: 8px; }
.file-ico { flex: none; width: 38px; height: 44px; border-radius: 6px; display: grid; place-items: center; font-size: 10.5px; font-weight: 700; color: #fff; letter-spacing: .03em; }
.file-ico.pdf { background: #c8372d; }
.file-ico.doc { background: #2b5797; }
.draft-card .draft-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.draft-card .draft-file { display: flex; gap: 10px; align-items: center; min-width: 0; }
.draft-card .draft-file b { word-break: break-all; }
.draft-frame { width: 100%; height: 640px; border: 0; display: block; background: #525659; border-radius: 0 0 var(--radius) var(--radius); }
.draft-word { padding: 26px 20px; text-align: center; color: var(--ink-2); }
.draft-versi { padding: 10px 20px 14px; border-top: 1px solid var(--line); font-size: 13px; }
.draft-versi summary { cursor: pointer; color: var(--navy); font-weight: 600; }
.draft-versi ul { margin: 8px 0 0; padding-left: 18px; }
.draft-versi li { padding: 3px 0; }
@media (max-width: 760px) { .draft-frame { height: 460px; } }
