/* =========================================================
   DocuGen — tema "Aussie Palette" (Flat UI Colors · AU)
   Deep Koamaru #30336b · Greenland Green #22a6b3 · Turbo #f9ca24
   Exodus Fruit #686de0 · Carmine Pink #eb4d4b · Pure Apple #6ab04c
   Coastal Breeze #dff9fb · Hint of Ice Pack #c7ecee · Middle Blue #7ed6df
   Beekeeper #f6e58d · Spiced Nectarine #ffbe76 · Pink Glamour #ff7979
   Deep Cove #130f40 · Wizard Grey #535c68 · Soaring Eagle #95afc0
   ========================================================= */
:root {
  --bg: #f2fbfc;
  --bg-2: #dff9fb;          /* Coastal Breeze */
  --card: #ffffff;
  --ink: #130f40;           /* Deep Cove */
  --ink-soft: #535c68;      /* Wizard Grey */
  --line: #c7ecee;          /* Hint of Ice Pack */
  --line-2: #95afc0;        /* Soaring Eagle */
  --navy: #30336b;          /* Deep Koamaru */
  --teal: #22a6b3;          /* Greenland Green */
  --teal-dark: #1a838d;
  --teal-pale: #dff9fb;
  --sky: #7ed6df;           /* Middle Blue */
  --violet: #686de0;        /* Exodus Fruit */
  --violet-pale: #e9eafb;
  --yellow: #f9ca24;        /* Turbo */
  --yellow-pale: #fdf6cf;   /* tint Beekeeper */
  --orange: #f0932b;        /* Quince Jelly */
  --red: #eb4d4b;           /* Carmine Pink */
  --red-pale: #ffe3e3;      /* tint Pink Glamour */
  --green: #6ab04c;         /* Pure Apple */
  --green-pale: #eaf6d6;    /* tint June Bud */
  --shadow: 0 1px 2px rgba(19,15,64,.06), 0 6px 18px rgba(48,51,107,.08);
  --radius: 12px;
  --f-head: "Nunito", "Segoe UI", system-ui, sans-serif;
  --f-body: "Nunito Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-ar: "Noto Naskh Arabic", "Traditional Arabic", "Arial", serif;
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; color: var(--ink); font-family: var(--f-body); line-height: 1.5;
  background: var(--bg) linear-gradient(180deg, var(--bg-2) 0, var(--bg) 320px) no-repeat;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--teal-dark); }
h1, h2, h3, h4 { font-family: var(--f-head); font-weight: 800; line-height: 1.2; margin: 0 0 .5rem; color: var(--navy); }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
code, .mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .92em; }
.ar { font-family: var(--f-ar); direction: rtl; unicode-bidi: plaintext; }
.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }
.lead { font-size: 1.2rem; margin: 0; }
.pagehead .lead { text-align: left; }
.err-text { color: var(--red); font-weight: 600; }
.ok-text { color: #3f7f27; font-weight: 600; }
.mt { margin-top: 1.5rem; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: .7rem 1.5rem; background: var(--navy); color: #fff;
  border-bottom: 4px solid var(--yellow);
  position: relative;
}
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -8px; height: 4px; background: linear-gradient(90deg, var(--teal) 0 25%, var(--violet) 25% 50%, var(--red) 50% 75%, var(--green) 75%); }
.brand { display: flex; align-items: center; gap: .7rem; color: inherit; text-decoration: none; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--yellow); color: var(--navy); font-family: var(--f-head); font-weight: 900;
}
.brand-text strong { display: block; font-family: var(--f-head); font-weight: 800; font-size: 1.1rem; }
.brand-text small { display: block; color: var(--sky); font-size: .75rem; }
.mainnav { display: flex; gap: .25rem; flex-wrap: wrap; }
.mainnav a { color: #dfe3ff; text-decoration: none; padding: .45rem .9rem; border-radius: 999px; font-weight: 600; }
.mainnav a:hover { background: rgba(255,255,255,.1); }
.mainnav a.on { background: var(--teal); color: #fff; }
.userbox { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.userbox form { margin: 0; }
.userchip { display: flex; align-items: center; gap: .5rem; color: inherit; text-decoration: none; padding: .2rem .7rem .2rem .2rem; border-radius: 999px; }
.userchip:hover, .userchip.on { background: rgba(255,255,255,.1); }
.userchip small { display: block; color: var(--sky); font-size: .72rem; line-height: 1; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--violet); color: #fff; display: grid; place-items: center; font-weight: 800; }

/* ---------- layout ---------- */
.wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 2rem 1.5rem 3rem; flex: 1; }
.foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; padding: 1rem 1.5rem; color: var(--ink-soft); font-size: .8rem; border-top: 1px solid var(--line); background: #fff; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 800; color: var(--teal-dark); margin: 0 0 .25rem; }
.eyebrow a { color: inherit; }
.cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; margin-top: 1.25rem; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }
.btnrow { display: flex; gap: .5rem; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: .85rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem 1.4rem; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 520px; margin: 0 auto; }
.empty { padding: 2rem; text-align: center; color: var(--ink-soft); margin: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: 700 .9rem var(--f-body); color: var(--navy); background: #fff;
  border: 1.5px solid var(--line-2); border-radius: 9px; padding: .5rem 1rem; cursor: pointer;
  text-decoration: none; transition: background .15s, border-color .15s, transform .08s, box-shadow .15s;
}
.btn:hover { border-color: var(--navy); box-shadow: 0 3px 10px rgba(48,51,107,.12); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.btn.pdf { background: var(--red); border-color: var(--red); color: #fff; }
.btn.pdf:hover { background: #d63c3a; border-color: #d63c3a; }
.btn.danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: var(--red); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--line-2); }
.topbar .btn.ghost { color: #fff; border-color: rgba(255,255,255,.4); }
.topbar .btn.ghost:hover { border-color: #fff; box-shadow: none; }
.btn.sm { padding: .3rem .7rem; font-size: .8rem; border-radius: 7px; }
.btn.block { width: 100%; }
.linkbtn { background: none; border: 0; color: var(--teal-dark); text-decoration: underline; cursor: pointer; font-size: .78rem; font-family: var(--f-body); }
.genbtns { display: flex; gap: .35rem; flex-wrap: wrap; }
.genbtns form { margin: 0; flex: 1; }
.genbtns .btn { width: 100%; }
.actions .genbtns { display: inline-flex; vertical-align: middle; }
.actions .genbtns form { flex: none; }

/* ---------- forms ---------- */
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .9rem; }
input, select, textarea {
  font: 400 1rem var(--f-body); color: var(--ink); background: #fff;
  border: 1.5px solid var(--line); border-radius: 9px; padding: .55rem .75rem; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(34,166,179,.25); border-color: var(--teal); }
input.ar { font-family: var(--f-ar); font-size: 1.1rem; text-align: right; }
.check { flex-direction: row; align-items: flex-start; gap: .55rem; font-weight: 400; }
.check input { width: auto; margin-top: .25rem; accent-color: var(--teal); }

.recordform .section { margin-bottom: 1.25rem; }
.recordform legend {
  font-family: var(--f-head); font-weight: 800; font-size: 1.05rem; padding: .25rem .9rem .25rem .3rem; color: var(--navy);
  background: var(--yellow-pale); border: 1.5px solid var(--yellow); border-radius: 999px; display: flex; align-items: center; gap: .5rem;
}
.secno { width: 26px; height: 26px; border-radius: 50%; background: var(--navy); color: var(--yellow); display: grid; place-items: center; font-size: .8rem; }
fieldset.section:nth-of-type(2) legend { background: var(--violet-pale); border-color: var(--violet); }
fieldset.section:nth-of-type(3) legend { background: var(--teal-pale); border-color: var(--teal); }
fieldset.section:nth-of-type(4) legend { background: var(--green-pale); border-color: var(--green); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1.2rem; }
@media (max-width: 680px) { .grid { grid-template-columns: 1fr; } }
.field.wide { grid-column: 1 / -1; }
.flabel { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); font-weight: 800; }
.req { color: var(--red); }
.field.has-err input, .field.has-err textarea { border-color: var(--red); background: #fff7f7; }
.ferr { color: var(--red); font-size: .8rem; font-weight: 600; }
.words { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .9rem 1.2rem; margin: 1rem 0; padding: .9rem 1rem; background: var(--teal-pale); border: 1.5px dashed var(--sky); border-radius: 10px; }
.words output { display: block; font-weight: 700; margin-top: .2rem; color: var(--navy); }
.words output.ar { font-size: 1.15rem; }
.formbar { position: sticky; bottom: .75rem; display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; padding: .85rem 1rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(48,51,107,.16); }

/* ---------- flash ---------- */
.flash { border-radius: 10px; padding: .75rem 1rem; margin-bottom: 1rem; background: #fff; border: 1px solid var(--line); border-left-width: 5px; }
.flash.ok { background: var(--green-pale); border-color: var(--green); }
.flash.err { background: var(--red-pale); border-color: var(--red); }
.flash.warn { background: var(--yellow-pale); border-color: var(--yellow); }
.pwbox code.pw { font-size: 1.3rem; background: #fff; padding: .15rem .6rem; border: 1.5px dashed var(--navy); border-radius: 6px; margin: 0 .4rem; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--navy); background: var(--bg-2); padding: .75rem .8rem; border-bottom: 1px solid var(--line); white-space: nowrap; font-weight: 800; }
.table td { padding: .7rem .8rem; border-bottom: 1px solid #e8f6f7; vertical-align: top; }
.table tbody tr:hover td { background: #f7fdfd; }
.table tr.dim td { opacity: .55; }
.num { text-align: right; white-space: nowrap; }
.actions { text-align: right; white-space: nowrap; }
.tag { display: inline-block; padding: .12rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 800; background: var(--violet-pale); color: var(--violet); white-space: nowrap; }
.tag-admin { background: var(--navy); color: var(--yellow); }
.fmt { display: inline-block; font-size: .68rem; font-weight: 800; padding: 0 .4rem; border-radius: 5px; vertical-align: middle; }
.fmt-docx { background: #e3ecfb; color: #2b579a; }
.fmt-pdf { background: var(--red-pale); color: var(--red); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { border-radius: var(--radius); padding: 1rem 1.2rem; background: #fff; box-shadow: var(--shadow); color: var(--ink-soft); font-size: .85rem; font-weight: 600; border-top: 5px solid var(--teal); }
.stat:nth-child(2) { border-top-color: var(--yellow); }
.stat:nth-child(3) { border-top-color: var(--violet); }
.stat span { display: block; font-family: var(--f-head); font-weight: 900; font-size: 2.1rem; color: var(--navy); line-height: 1.1; }

.searchbar, .filterbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.searchbar input { flex: 1; min-width: 240px; }
.searchbar .sel-user { width: auto; min-width: 200px; }
.filterbar label { min-width: 150px; }
.pager { display: flex; gap: .3rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.pager a, .pager span { padding: .3rem .75rem; border-radius: 8px; text-decoration: none; color: var(--navy); background: #fff; border: 1px solid var(--line); font-weight: 700; }
.pager .on { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------- documents ---------- */
.docs { background: var(--navy); color: #fff; border-radius: 16px; padding: 1.3rem; box-shadow: var(--shadow); }
.docs > .docs-head h2 { color: #fff; }
.docs > .docs-head .muted { color: var(--sky); }
.docs-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.docs-head form { margin: 0; }
.docgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; }
.doccard {
  position: relative; background: #fff; color: var(--ink); border-radius: var(--radius);
  padding: 2.5rem 1rem 1rem; display: flex; flex-direction: column; gap: .35rem; overflow: hidden;
}
.doccard::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 7px; background: var(--teal); }
.doccard:nth-child(2)::before { background: var(--yellow); }
.doccard:nth-child(3)::before { background: var(--red); }
.doccard:nth-child(4)::before { background: var(--violet); }
.doccard:nth-child(5)::before { background: var(--green); }
.doccard h3 { margin: 0; }
.doccard h3.ar { font-family: var(--f-ar); font-size: 1.15rem; text-align: right; }
.doccard .genbtns { margin-top: auto; }
.gencol { margin-top: auto; display: flex; flex-direction: column; gap: .3rem; }
.gencol .genbtns { margin-top: 0; }
.doccard.locked { opacity: .6; }
.docno { position: absolute; top: 15px; left: 14px; font-family: var(--f-head); font-weight: 900; color: var(--line-2); }
.lang { position: absolute; top: 15px; right: 12px; font-size: .68rem; font-weight: 800; letter-spacing: .06em; background: var(--bg-2); color: var(--navy); border-radius: 999px; padding: .05rem .5rem; }

.workers { margin-top: 1.25rem; }
.bulk { margin-top: 1rem; border-top: 1px dashed var(--line); padding-top: .8rem; }
.bulk summary { cursor: pointer; font-weight: 800; color: var(--teal-dark); }
.bulk form { margin-top: .8rem; }

.dlhead { margin-top: 1.1rem; font-size: .76rem; text-transform: uppercase; letter-spacing: .12em; color: var(--teal-dark); font-family: var(--f-body); font-weight: 800; }
.dl { display: grid; grid-template-columns: minmax(140px, 38%) 1fr; margin: 0; }
.dl dt, .dl dd { padding: .45rem 0; border-bottom: 1px solid #e8f6f7; margin: 0; }
.dl dt { color: var(--ink-soft); font-size: .85rem; padding-right: .8rem; }
.dl dd.ar { text-align: right; font-size: 1.05rem; }

.timeline { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow: auto; }
.timeline li { padding: .55rem 0 .55rem 1rem; border-left: 3px solid var(--sky); margin-left: .3rem; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: .9rem; width: 11px; height: 11px; border-radius: 50%; background: #fff; border: 3px solid var(--teal); }
.timeline time { display: block; font-size: .78rem; color: var(--ink-soft); font-family: ui-monospace, Menlo, monospace; }
.danger-zone { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px dashed var(--line); }

.perms { display: grid; gap: 1rem; }
.permgroup { border: 1px solid var(--line); background: #fbfeff; border-radius: 10px; padding: .75rem .9rem; display: grid; gap: .45rem; }
.permgroup h4 { font-size: .9rem; display: flex; justify-content: space-between; align-items: center; margin: 0; }
.ticks { list-style: none; padding: 0; }
.ticks li::before { content: "✓ "; color: var(--green); font-weight: 900; }
.ticks li.no { color: var(--ink-soft); text-decoration: line-through; }
.ticks li.no::before { content: "✕ "; color: var(--red); }

/* ---------- login ---------- */
.login { display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem; align-items: center; max-width: 920px; margin: 3rem auto; }
@media (max-width: 760px) { .login { grid-template-columns: 1fr; } .login-art { display: none; } }
.login-art p { font-family: var(--f-head); font-weight: 700; font-size: 1.1rem; color: var(--ink-soft); max-width: 340px; }
.stamp {
  width: 170px; height: 170px; border-radius: 36px; display: grid; place-items: center; text-align: center;
  font-family: var(--f-head); font-weight: 900; font-size: 2.3rem; line-height: 1; color: var(--navy);
  background: var(--yellow); transform: rotate(-8deg); margin-bottom: 1.5rem;
  box-shadow: 14px 14px 0 var(--teal), 28px 28px 0 var(--violet);
}
.login-card { display: flex; flex-direction: column; gap: .9rem; }

@media print { .topbar, .foot, .btn { display: none !important; } body { background: #fff; } }

/* ---------- logo & kop surat ---------- */
.logobox { display: flex; gap: 1.2rem; align-items: center; margin-top: 1rem; padding: 1rem; border: 1.5px dashed var(--line-2); border-radius: 10px; background: #fbfeff; }
.logobox.has-err { border-color: var(--red); background: #fff7f7; }
.logobox input[type=file] { padding: .45rem; background: #fff; }
.logoprev { width: 120px; height: 100px; flex: none; display: grid; place-items: center; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.logoprev img { max-width: 100%; max-height: 100%; object-fit: contain; }
.kopprev { margin-bottom: 1.25rem; }
.kop { display: grid; grid-template-columns: 140px 1fr; align-items: center; gap: 1rem; padding: .6rem 1rem 1rem; border-bottom: 2px solid #555; background: #fff; font-family: "Times New Roman", Georgia, serif; color: #1f1f1f; }
.kop-logo { height: 90px; display: grid; place-items: center; }
.kop-logo img { max-width: 120px; max-height: 90px; object-fit: contain; }
.kop-logo span { width: 110px; height: 80px; display: grid; place-items: center; border: 1.5px dashed var(--line-2); border-radius: 8px; color: var(--line-2); font-family: var(--f-body); font-size: .85rem; }
.kop-text { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .1rem; }
.kop-text strong { font-size: 1.35rem; letter-spacing: .02em; }
.kop-text .ar { font-family: var(--f-ar); font-weight: 700; font-size: 1.15rem; }
.kopprev > p { margin: .6rem 0 0; }
@media (max-width: 600px) { .kop { grid-template-columns: 1fr; } .logobox { flex-direction: column; align-items: flex-start; } }
