:root {
  --bg: #f6f5f1; --card: #ffffff; --ink: #1c1b18; --muted: #6b6860; --line: #e4e1d8;
  --accent: #1f6b4f; --accent-ink: #ffffff; --danger: #b3261e; --soft: #eef3ef; --warn: #fff6e0;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151512; --card: #1f1e1b; --ink: #f0eee7; --muted: #a29f95; --line: #34322d;
    --accent: #5fbf98; --accent-ink: #0d1f17; --danger: #ff8a80; --soft: #22302a; --warn: #33290f;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px 64px; }

/* header */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 12px; padding-top: 10px; padding-bottom: 10px; }
.brand { font-weight: 700; font-size: 18px; flex: 1; }
.who { color: var(--muted); font-size: 14px; }
.tabs { display: flex; gap: 6px; padding: 12px 0 4px; }
.tab { border: 1px solid var(--line); background: var(--card); padding: 8px 16px; border-radius: 999px; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* buttons & fields */
.btn { border: 1px solid var(--line); background: var(--card); padding: 8px 14px; border-radius: 10px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 14px; }
.btn.link { border: 0; background: none; padding: 2px 4px; color: var(--accent); text-decoration: underline; }
.btn:disabled { opacity: .5; cursor: default; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 14px; color: var(--muted); }
input[type=text], input[type=password], input[type=search], input[type=number], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
}
textarea { min-height: 80px; resize: vertical; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* layout bits */
.bar { display: flex; gap: 10px; align-items: center; margin: 14px 0; flex-wrap: wrap; }
.bar .grow { flex: 1; min-width: 160px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.list { display: grid; gap: 8px; }
.row-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; width: 100%; cursor: pointer; }
.row-item .name { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.pill { display: inline-block; font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--soft); color: var(--accent); }
.empty { padding: 28px 8px; text-align: center; color: var(--muted); }
.crumb { margin: 14px 0 4px; }
.head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 12px; }
.head h2 { flex: 1; min-width: 180px; }

/* design rows */
.drow { display: grid; grid-template-columns: 110px 1fr auto; gap: 8px 14px; align-items: start; padding: 12px 0; border-top: 1px solid var(--line); }
.drow:first-child { border-top: 0; }
.dno { font-weight: 700; font-size: 17px; }
.rates div { margin-bottom: 2px; }
.acts { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.note { margin-top: 4px; padding: 6px 10px; border-radius: 8px; background: var(--warn); font-size: 14px; }
@media (max-width: 620px) {
  .drow { grid-template-columns: 1fr; }
  .acts { justify-content: flex-start; }
}

/* cards grid */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 8px; }
.jc { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.jc .thumb { display: block; width: 100%; aspect-ratio: 3/4; object-fit: cover; background: var(--soft); }
.jc .pdf { display: flex; align-items: center; justify-content: center; aspect-ratio: 3/4; background: var(--soft); font-weight: 700; color: var(--danger); font-size: 22px; }
.jc .meta { padding: 8px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }

/* dialog */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(460px, calc(100vw - 24px)); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.dlg { padding: 18px; }
.dlg h3 { margin-bottom: 12px; }
.dlg .btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; margin-top: 4px; }


/* toast */
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100vw - 32px); z-index: 20; }
#toast.on { opacity: 1; }
table.hist { width: 100%; border-collapse: collapse; font-size: 14px; }
table.hist td, table.hist th { padding: 6px 4px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }

.pre { white-space: pre-wrap; }
.fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- login ---------------- */
.lg { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
.lg-brand { position: relative; display: flex; align-items: center; justify-content: center; padding: 48px; color: #f4efe3; overflow: hidden;
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(255,255,255,.10), transparent 60%),
    linear-gradient(160deg, #164f3a 0%, #0f3a2a 55%, #0b2c20 100%); }
.lg-brand::before { content: ""; position: absolute; inset: 0; opacity: .5;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,.045) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.045) 0 1px, transparent 1px 7px); }
.lg-brand::after { content: ""; position: absolute; width: 520px; height: 520px; right: -220px; bottom: -220px; border-radius: 50%;
  border: 1px solid rgba(244,239,227,.18); box-shadow: 0 0 0 40px rgba(244,239,227,.04), 0 0 0 90px rgba(244,239,227,.03); }
.lg-brand-in { position: relative; z-index: 1; max-width: 340px; }
.lg-mark { width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; font: 600 20px/1 Georgia, "Iowan Old Style", Cambria, serif; letter-spacing: .08em;
  border: 1px solid rgba(244,239,227,.45); margin-bottom: 28px; }
.lg-brand h1 { font: 500 44px/1.05 Georgia, "Iowan Old Style", Cambria, "Times New Roman", serif; letter-spacing: .01em; margin: 0; }
.lg-rule { width: 56px; height: 2px; background: #d9c27a; margin: 22px 0 16px; border-radius: 2px; }
.lg-brand p { margin: 0; text-transform: uppercase; letter-spacing: .28em; font-size: 12px; opacity: .8; }

.lg-panel { display: flex; align-items: center; justify-content: center; padding: 32px 20px; background: var(--bg); }
.lg-form { width: 100%; max-width: 380px; }
.lg-form h2 { font-size: 28px; letter-spacing: -.01em; margin: 0; }
.lg-sub { color: var(--muted); margin: 6px 0 28px; }
.lg-field { display: block; margin-bottom: 16px; }
.lg-field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.lg-input { display: flex; align-items: center; gap: 10px; padding: 0 12px; height: 48px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--muted); transition: border-color .15s, box-shadow .15s; }
.lg-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,107,79,.18); color: var(--accent); }
.lg-input input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; padding: 0; font-size: 16px; color: var(--ink); width: auto; }
.lg-input input::placeholder { color: var(--muted); opacity: .7; }
.lg-eye { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px; margin-right: -6px; border-radius: 8px; display: grid; place-items: center; }
.lg-eye:hover { color: var(--ink); }
.lg-caps { font-size: 13px; color: #8a5a00; background: var(--warn); border-radius: 8px; padding: 6px 10px; margin: -4px 0 12px; }
.lg-err { min-height: 20px; color: var(--danger); font-size: 14px; margin: 2px 0 12px; }
.lg-btn { width: 100%; height: 48px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 16px; font-weight: 600; cursor: pointer; letter-spacing: .01em; transition: filter .15s, transform .05s; }
.lg-btn:hover { filter: brightness(1.06); }
.lg-btn:active { transform: translateY(1px); }
.lg-btn:disabled { cursor: default; opacity: .75; }
.lg-btn.busy .lg-btn-t::after { content: ""; display: inline-block; width: 14px; height: 14px; margin-left: 10px; vertical-align: -2px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: lgspin .7s linear infinite; }
@keyframes lgspin { to { transform: rotate(360deg); } }
.lg-foot { text-align: center; color: var(--muted); font-size: 13px; margin: 22px 0 0; }
@media (max-width: 820px) {
  .lg { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .lg-brand { padding: 28px 24px; justify-content: flex-start; }
  .lg-brand-in { display: flex; align-items: center; gap: 14px; max-width: none; flex-wrap: wrap; }
  .lg-mark { width: 44px; height: 44px; margin: 0; font-size: 16px; border-radius: 11px; }
  .lg-brand h1 { font-size: 28px; }
  .lg-rule, .lg-brand p { display: none; }
  .lg-brand::after { display: none; }
  .lg-panel { align-items: flex-start; padding-top: 36px; }
}
@media (prefers-reduced-motion: reduce) { .lg-btn.busy .lg-btn-t::after { animation: none; } }
