/* DUSON LAW navy (logo #01083E). Layout language follows ai-studio-admin /new27:
   white header with a 3px brand line, soft pill nav, 14px panels, bold buttons with tinted shadow. */
:root {
  --brand: #01083e;
  --ink: #1e2433; --ink-2: #3f4655; --muted: #687083; --line: #e7e9ee; --line-2: #d5d9e1;
  --bg: #f4f6f8; --card: #fff; --soft: #fafbfc;
  --accent: #0b1a5c; --accent-hover: #01083e; --accent-text: #0b1a5c; --accent-soft: #eef0f8; --accent-soft-border: #cfd5ea;
  --secondary: #eef1f5; --secondary-hover: #e3e8ef; --secondary-text: #566072;
  --gold: #c2a26b;
  --ok: #067647; --ok-soft: #ecfdf3; --err: #b42318; --err-soft: #fef3f2; --warn: #b54708; --warn-soft: #fffaeb;
  --info: #175cd3; --info-soft: #eff8ff;
  --radius: 14px; --shadow: 0 2px 10px rgba(40, 50, 70, .05); --shadow-lg: 0 10px 28px -10px rgba(1, 8, 62, .22);
  --btn-shadow: 0 2px 6px rgba(1, 8, 62, .25);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 76px; }
body {
  margin: 0; color: var(--ink); background: var(--bg);
  font: 14.5px/1.55 -apple-system, "Segoe UI Variable Text", "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
a.plain { color: inherit; }
b, strong { font-weight: 600; }

/* --- top bar --- */
header { position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, .95); backdrop-filter: saturate(1.4) blur(8px);
  border-top: 3px solid var(--brand); border-bottom: 1px solid var(--line); box-shadow: 0 1px 4px rgba(40, 50, 70, .04); }
.bar { max-width: 1200px; margin: 0 auto; padding: 0 24px; height: 60px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: baseline; gap: 6px; color: var(--brand); font-weight: 800; font-size: 17px; letter-spacing: .01em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand small { font-weight: 700; font-size: 11px; color: var(--secondary-text); background: var(--secondary); border-radius: 6px; padding: 2px 7px; letter-spacing: .02em; }
.links { display: flex; gap: 4px; flex: 1; }
.links { gap: 6px; flex-wrap: wrap; }
.links a { color: var(--secondary-text); background: var(--secondary); padding: 6px 12px; border-radius: 8px; font-weight: 700; font-size: 13px; transition: background .12s, color .12s; }
.links a:hover { background: var(--accent-soft); color: var(--accent-text); text-decoration: none; }
.links a.on { color: #fff; background: var(--accent); box-shadow: var(--btn-shadow); }
.actions { display: flex; align-items: center; gap: 14px; }
.actions form { margin: 0; }

/* --- layout --- */
main { max-width: 1200px; margin: 0 auto; padding: 28px 24px 80px; }
h1 { font-size: 23px; line-height: 1.3; margin: 0; letter-spacing: -.01em; font-weight: 800; color: #161c2b; }
h1 .sub { font-size: 16px; font-weight: 400; color: var(--muted); margin-left: 6px; }
h2 { font-size: 15px; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; font-weight: 700; color: #1e2433; }
/* /new27 step badge: <span class="step">1</span> before a section title */
.step { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; flex: none; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 12.5px; font-weight: 700; box-shadow: 0 1px 3px rgba(1, 8, 62, .35); }
.step.done { background: var(--ok); box-shadow: none; }
h3 { font-size: 14px; margin: 18px 0 8px; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; } .crumbs a { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 18px 22px 0; }
.card.flush > .empty { margin: 18px 22px; }
.card.highlight { border-color: var(--accent-soft-border); background: var(--accent-soft); }
.card.narrow { max-width: 400px; margin: 72px auto; display: grid; gap: 14px; padding: 28px; box-shadow: var(--shadow-lg); }
.danger-zone { border-color: #fecdca; }
.danger-zone h2 { color: var(--err); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px 20px; }
.grid .full { grid-column: 1 / -1; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 0 18px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.row.tight { gap: 6px; margin: 0; } .row.spread { justify-content: space-between; }
.inline { display: inline; margin: 0; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=search] { max-width: 340px; }
.toolbar select { width: auto; }
.savebar { position: sticky; bottom: 0; z-index: 5; display: flex; gap: 10px; justify-content: flex-end; padding: 12px 0; margin: -4px 0 18px;
  background: linear-gradient(0deg, var(--bg) 70%, rgba(245, 246, 248, 0)); }
.card .savebar { background: none; padding-bottom: 0; margin: 12px 0 0; position: static; }

/* --- forms --- */
label, .lbl { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
label > input, label > select, label > textarea { margin-top: 5px; }
input, select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--line-2); border-radius: 8px; font: inherit; color: var(--ink); background: #fff;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #8098d9; box-shadow: 0 0 0 3px rgba(29, 58, 138, .12); }
input:invalid:not(:placeholder-shown):not(:focus) { border-color: #fda29b; }
textarea { resize: vertical; }
.hint { font-size: 12.5px; color: var(--muted); font-weight: 400; } .hint.big { font-size: 15px; }
.empty { color: var(--muted); font-size: 13.5px; margin: 4px 0; }
.seg { display: flex; gap: 18px; margin: 6px 0 14px; }
.seg label, .check { display: inline-flex; gap: 7px; align-items: center; color: var(--ink); font-size: 14px; font-weight: 400; }
.seg input, .check input, .classes input { width: auto; margin: 0; accent-color: var(--accent); }

/* --- buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: 8px;
  border: 1px solid var(--accent); background: var(--accent); color: #fff; font: inherit; font-weight: 700; font-size: 14px;
  cursor: pointer; text-decoration: none; white-space: nowrap; box-shadow: var(--btn-shadow); transition: background .15s, transform .1s, box-shadow .15s;
}
.btn:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; transform: translateY(-1px); }
.btn.secondary { background: #fff; color: var(--secondary-text); border-color: var(--line); box-shadow: none; }
.btn.secondary:hover:not(:disabled) { background: var(--secondary); border-color: var(--line); color: var(--ink-2); }
.btn.danger { background: #fff; color: var(--err); border-color: #fda29b; box-shadow: none; }
.btn.danger:hover:not(:disabled) { background: var(--err); color: #fff; border-color: var(--err); }
.btn.small { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { background: #e6e9ee; border-color: #e6e9ee; color: #9aa2b1; box-shadow: none; cursor: not-allowed; }
.linkbtn { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; font-size: 13px; }
.linkbtn:hover { text-decoration: underline; }
.linkbtn.quiet { color: var(--muted); } .linkbtn.danger { color: var(--err); }
.iconbtn { background: none; border: 1px solid transparent; color: var(--muted); cursor: pointer; width: 26px; height: 26px; border-radius: 7px; font-size: 12px; vertical-align: middle; }
.iconbtn:hover { color: var(--err); background: var(--err-soft); border-color: #fecdca; }

/* --- tables --- */
.table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 600; background: var(--soft); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fbfcfe; }
.card:not(.flush) .table { margin: 0 -22px; padding: 0; } .card:not(.flush) .table table { min-width: 100%; }
.card:not(.flush) th:first-child, .card:not(.flush) td:first-child { padding-left: 22px; }
.card:not(.flush) th:last-child, .card:not(.flush) td:last-child { padding-right: 22px; }
.card.flush th:first-child, .card.flush td:first-child { padding-left: 22px; }
.card.flush th:last-child, .card.flush td:last-child { padding-right: 22px; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.right { text-align: right; } .nowrap { white-space: nowrap; }
table.small td, table.small th { font-size: 13px; padding: 5px 7px; }
tr.overdue td { color: var(--err); } tr.overdue td a { color: var(--err); }
tr.warn td { background: var(--warn-soft); }

/* --- details (inline edit) --- */
details.edit { display: inline-block; margin-left: 6px; vertical-align: baseline; }
details.edit > summary { list-style: none; cursor: pointer; color: var(--muted); font-size: 12.5px; display: inline; }
details.edit > summary::-webkit-details-marker { display: none; }
details.edit > summary:hover { color: var(--accent); text-decoration: underline; }
details.edit[open] { display: block; margin: 8px 0 2px; }
details.edit[open] > summary { color: var(--accent); }
details.edit[open] > form { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: flex-start; }
details.edit[open] > form textarea { flex: 1 1 100%; }
td details.edit { display: block; margin: 4px 0 0; }

/* --- flash, pills --- */
.flash { padding: 11px 15px; border-radius: 10px; margin-bottom: 16px; border: 1px solid transparent; font-size: 14px; }
.flash.ok { background: var(--ok-soft); color: var(--ok); border-color: #abefc6; }
.flash.error { background: var(--err-soft); color: var(--err); border-color: #fecdca; }
.pill { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-text); font-size: 12px; font-weight: 700; white-space: nowrap; line-height: 1.6; }
.pill.muted { background: #f2f4f7; color: var(--muted); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
a.pill:hover { text-decoration: none; filter: brightness(.97); }
em.bad { color: var(--err); font-style: normal; font-weight: 600; }

/* --- dashboard tiles --- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 18px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; color: var(--ink); display: grid; gap: 2px; box-shadow: var(--shadow); transition: box-shadow .15s, transform .15s; }
a.tile:hover { text-decoration: none; box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.tile span { font-size: 12px; color: var(--muted); font-weight: 700; }
.tile b { font-size: 30px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.25; }
.tile small { color: var(--muted); font-size: 12.5px; }
.tile.accent { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: var(--shadow-lg); }
.tile.accent span, .tile.accent small { color: rgba(255, 255, 255, .72); }
.tile.accent b { color: #fff; font-size: 26px; }

/* --- tabs --- */
.tabs { display: inline-flex; gap: 4px; padding: 3px; background: var(--secondary); border-radius: 9px; flex-wrap: wrap; }
.tab { padding: 6px 12px; border-radius: 7px; color: var(--secondary-text); font-weight: 700; font-size: 13px; }
.tab span { color: var(--muted); font-weight: 400; margin-left: 2px; }
.tab:hover { text-decoration: none; background: rgba(255, 255, 255, .6); }
.tab.on { background: #fff; color: var(--accent-text); box-shadow: 0 1px 4px rgba(1, 8, 62, .2); }

/* --- classes & goods --- */
.classes { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; margin: 6px 0 10px; }
.cls { border: 1px solid var(--line-2); border-radius: 8px; text-align: center; padding: 7px 0; cursor: pointer; color: var(--ink-2); font-size: 13.5px; font-weight: 500; user-select: none; transition: all .1s; background: #fff; }
.cls:hover { border-color: var(--accent); color: var(--accent); }
.cls input { display: none; }
.cls.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.goods { border-top: 1px solid var(--line); padding: 14px 0; }
.formats { display: grid; gap: 8px; margin-top: 10px; }
.formats code { display: block; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-family: inherit; font-size: 13px; line-height: 1.55; cursor: copy; white-space: pre-wrap; margin-top: 3px; }
.formats code:hover { border-color: var(--line-2); }
.formats code.copied { background: var(--ok-soft); border-color: #abefc6; }

/* --- image tools --- */
.image-tools { display: grid; grid-template-columns: 220px 1fr; gap: 22px; }
.preview { width: 220px; height: 220px; border: 1px solid var(--line); border-radius: 10px; display: grid; place-items: center; overflow: hidden;
  background: #fff repeating-conic-gradient(#f4f5f7 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.preview img, .thumb { max-width: 100%; max-height: 100%; background: #fff; }
.thumb { width: 120px; height: 120px; border: 1px solid var(--line); border-radius: 8px; }

/* --- memos --- */
.note-new { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 16px; }
.note-new textarea { flex: 1; }
.notes { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--line); display: grid; gap: 14px; }
.notes li { position: relative; }
.notes li::before { content: ""; position: absolute; left: -22px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); }
.note-meta { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.note-meta time { font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.note-tools { margin-left: auto; display: inline-flex; gap: 10px; align-items: baseline; }
.note-tools details.edit[open] { flex-basis: 100%; }
.notes li:has(details[open]) .note-body { display: none; }
.note-tools:has(details[open]) { flex-basis: 100%; flex-wrap: wrap; margin-left: 0; }
.note-body { white-space: pre-wrap; margin-top: 3px; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }

@media (max-width: 760px) {
  .bar { height: auto; padding: 10px 16px; flex-wrap: wrap; gap: 10px; }
  .links { order: 3; flex-basis: 100%; overflow-x: auto; }
  .actions { margin-left: auto; }
  main { padding: 20px 16px 70px; }
  .image-tools { grid-template-columns: 1fr; }
  .note-new { flex-direction: column; } .note-new .btn { align-self: flex-end; }
  .cols { grid-template-columns: 1fr; }
}

/* --- settings & deposits --- */
table.kv { width: auto; margin: 6px 0 4px; } table.kv th { background: none; text-transform: none; letter-spacing: 0; font-size: 13px; padding: 6px 24px 6px 0; } table.kv td { padding: 6px 0; }
table.kv tr:hover td { background: none; }
td.bad, .bad { color: var(--err); }
pre.raw { white-space: pre-wrap; word-break: break-all; font-size: 12px; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-height: 260px; overflow: auto; }
form.match { display: grid; gap: 6px; margin-bottom: 4px; }
form.match .check { align-items: flex-start; font-size: 13.5px; }
form.match .check input { margin-top: 3px; }
table.cands { margin: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
table.cands th, table.cands td { padding: 6px 8px; font-size: 13px; }
table.cands td:first-child, table.cands th:first-child { padding-left: 8px !important; width: 24px; }
table.cands td:last-child, table.cands th:last-child { padding-right: 8px !important; }
table.cands input { width: auto; margin: 2px 0 0; accent-color: var(--accent); }
td.good { color: var(--ok); font-weight: 600; } td.bad { color: var(--muted); }
td.sender { min-width: 160px; word-break: break-word; }
details.record { margin: 8px 0 4px; display: block; }
.record-form { display: grid !important; gap: 4px; margin-top: 6px; padding: 10px 12px; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; }
.record-form .check { font-size: 13.5px; align-items: flex-start; } .record-form .check input { margin-top: 3px; }
form.match > input[data-other] { font-size: 13px; padding: 6px 10px; }
.totalbar { padding: 8px 10px; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; }
[data-total] { font-size: 13px; } [data-total].good { color: var(--ok); } [data-total].warn { color: var(--warn); }
.amt { font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.newinv { padding: 2px 0; }
table.cands .inv { display: block; white-space: nowrap; }
table.cands .inv .amt { margin-left: 4px; }
table.cands .hint { white-space: normal; }
details.ko-fields { border: 1px dashed var(--line-2); border-radius: 10px; padding: 10px 14px; }
details.ko-fields > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-2); }
details.ko-fields[open] > summary { margin-bottom: 10px; }

/* --- analytics --- */
svg.chart { width: 100%; height: auto; display: block; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
svg.chart .mark { fill: var(--accent); }
svg.chart .hit { fill: transparent; }
svg.chart .bar:hover .mark { fill: var(--accent-hover); }
svg.chart .bar:hover .hit { fill: rgba(29, 58, 138, .06); }
table.rank td { padding-top: 7px; padding-bottom: 7px; }
.rank-label { font-size: 13px; word-break: break-all; }
.rank-bar { height: 4px; border-radius: 2px; background: var(--accent); opacity: .35; margin-top: 4px; }
.up { color: var(--ok); font-weight: 600; } .down { color: var(--err); font-weight: 600; }

/* --- stage track (matter page) --- */
.track { display: flex; gap: 4px; flex-wrap: wrap; margin: -6px 0 18px; padding: 0; list-style: none; }
.track li { font-size: 12px; font-weight: 700; color: #9aa2b1; background: var(--secondary); border-radius: 7px; padding: 4px 9px; }
.track li.done { color: var(--accent-text); background: var(--accent-soft); }
.track li.now { color: #fff; background: var(--accent); box-shadow: var(--btn-shadow); }
/* Soft callout (like /new27 backToggle) */
.callout { padding: 9px 12px; background: var(--accent-soft); border: 1px solid var(--accent-soft-border); border-radius: 9px; font-size: 13px; color: var(--ink-2); }
