:root {
  --ink: #16212e;
  --muted: #5b6878;
  --line: #dfe4ea;
  --bg: #f5f7f9;
  --card: #ffffff;
  --brand: #12365a;
  --brand-2: #1f6f78;
  --accent: #c8102e;
  --ok: #1d7a46;
  --warn: #a35c00;
  --bad: #b3261e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 33, 52, .06), 0 2px 8px rgba(16, 33, 52, .05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.5; }
a { color: var(--brand-2); }
h1, h2, h3 { line-height: 1.2; color: var(--brand); }
h1 { font-size: 1.8rem; margin: .2em 0 .6em; }
h2 { font-size: 1.25rem; margin: 1.4em 0 .6em; }
h3 { font-size: 1.05rem; margin: 1em 0 .4em; }
small, .muted { color: var(--muted); }
code { background: #eef1f4; padding: 0 .3em; border-radius: 4px; }

/* Header */
.topbar { background: var(--brand); color: #fff; }
.topbar .inner { max-width: 1280px; margin: 0 auto; padding: .7rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: .5rem; }
.brand .flags { font-size: .95rem; letter-spacing: 2px; }
.nav { display: flex; gap: .2rem; flex-wrap: wrap; margin-left: auto; align-items: center; }
.nav a, .nav button.linklike { color: #dbe6f2; text-decoration: none; padding: .4rem .65rem; border-radius: 6px; font-size: .93rem; background: none; border: 0; cursor: pointer; font: inherit; }
.nav a:hover, .nav a.active, .nav button.linklike:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav .cta { background: #fff; color: var(--brand); font-weight: 600; }
.nav .cta:hover { background: #e9f1f8; color: var(--brand); }
.badge-count { background: var(--accent); color: #fff; border-radius: 999px; font-size: .72rem; padding: 0 .45em; margin-left: .2em; }

main { max-width: 1280px; margin: 0 auto; padding: 1.4rem 1rem 3rem; }
main.narrow { max-width: 760px; }
footer.site { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }
footer.site .inner { max-width: 1280px; margin: 0 auto; padding: 1.2rem 1rem; display: flex; gap: 1rem; flex-wrap: wrap; justify-content: space-between; }

/* Cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
@media (max-width: 900px) { .grid.side { grid-template-columns: 1fr; } }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .6rem; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; box-shadow: var(--shadow); text-decoration: none; color: inherit; display: block; }
.kpi .n { font-size: 1.6rem; font-weight: 700; color: var(--brand); }
.kpi .l { color: var(--muted); font-size: .85rem; }
.kpi.bad .n { color: var(--bad); }
.kpi.warn .n { color: var(--warn); }

/* Tables */
table.list { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.list th, table.list td { text-align: left; padding: .5rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
table.list tr:hover td { background: #fafbfc; }
.table-wrap { overflow-x: auto; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.facts dt { color: var(--muted); font-size: .88rem; }
dl.facts dd { margin: 0; white-space: pre-wrap; }

/* Status pills */
.pill { display: inline-block; padding: .1em .6em; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #e8edf2; color: #344; white-space: nowrap; }
.st-submitted { background: #fff1d6; color: #7a4b00; }
.st-accepted, .st-awaiting_records, .st-records_review, .st-appointment { background: #e3eefc; color: #1a4a85; }
.st-drafting, .st-qa { background: #ece6fb; color: #4b2f8f; }
.st-delivered, .st-follow_up { background: #dff3e7; color: #17603a; }
.st-closed, .st-cancelled, .st-declined { background: #eceef0; color: #555; }
.st-on_hold { background: #fde3e1; color: #8a1f17; }
.inv-draft { background: #eceef0; color: #555; }
.inv-issued { background: #e3eefc; color: #1a4a85; }
.inv-paid { background: #dff3e7; color: #17603a; }
.inv-void { background: #fde3e1; color: #8a1f17; }
.due-bad { color: var(--bad); font-weight: 600; }
.due-warn { color: var(--warn); font-weight: 600; }

/* Forms */
form .field, form div:has(> label + input), form div:has(> label + select), form div:has(> label + textarea) { margin-bottom: .8rem; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=datetime-local], input[type=number], input[type=tel], input[type=url], input[type=search], select, textarea {
  width: 100%; padding: .55rem .65rem; border: 1px solid #c7d0da; border-radius: 7px; font: inherit; background: #fff; color: var(--ink);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc3e6; border-color: #6a9fd0; }
input[type=checkbox] { width: 1.05rem; height: 1.05rem; vertical-align: middle; margin-right: .4rem; }
div:has(> input[type=checkbox]) { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .2rem; }
div:has(> input[type=checkbox]) > label { order: 2; flex: 1; font-weight: 500; }
div:has(> input[type=checkbox]) > input { order: 1; margin-top: .2rem; }
div:has(> input[type=checkbox]) > .helptext, div:has(> input[type=checkbox]) > ul.errorlist { order: 3; width: 100%; }
.helptext { display: block; color: var(--muted); font-size: .82rem; margin-top: .2rem; }
.helptext ul { margin: .2rem 0; padding-left: 1.2rem; }
ul.errorlist { color: var(--bad); margin: .2rem 0; padding-left: 1.1rem; font-size: .88rem; }
input[name=website] { position: absolute; left: -5000px; }
label[for=id_website] { position: absolute; left: -5000px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; margin: 0 0 1rem; }
legend { font-weight: 700; color: var(--brand); padding: 0 .3rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 1rem; }

.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .5rem .95rem; border-radius: 7px; border: 1px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; font-size: .93rem; }
.btn:hover { background: #0d2945; }
.btn.secondary { background: #fff; color: var(--brand); }
.btn.secondary:hover { background: #eef3f8; }
.btn.small { padding: .25rem .6rem; font-size: .83rem; }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }

/* Messages */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: .7rem 1rem; border-radius: 8px; margin-bottom: .5rem; border: 1px solid; }
.messages .success { background: #e8f6ee; border-color: #b6e1c6; color: #145233; }
.messages .info { background: #e9f2fb; border-color: #bcd6f0; color: #173f66; }
.messages .warning { background: #fff5e0; border-color: #f0d49a; color: #6b4400; }
.messages .error { background: #fdecea; border-color: #f2b8b2; color: #7d1a12; }
.notice { padding: .7rem 1rem; border-radius: 8px; background: #fff5e0; border: 1px solid #f0d49a; color: #6b4400; margin-bottom: 1rem; font-size: .92rem; }
.notice.info { background: #e9f2fb; border-color: #bcd6f0; color: #173f66; }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 .9rem 1.4rem; border-left: 2px solid var(--line); margin-left: .4rem; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: .3rem; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--brand-2); }
.timeline li.k-status::before { border-color: var(--brand); background: var(--brand); }
.timeline li.k-report::before { border-color: var(--ok); background: var(--ok); }
.timeline li.k-ai::before, .timeline li.k-translation::before { border-color: #6b4bc4; }
.timeline li.k-access::before, .timeline li.k-note::before { border-color: #aab3bd; }
.timeline .when { font-size: .8rem; color: var(--muted); }
.timeline .private { font-size: .72rem; background: #eceef0; padding: 0 .4em; border-radius: 4px; color: #555; margin-left: .3rem; }

/* Messages thread */
.thread { display: flex; flex-direction: column; gap: .6rem; max-height: 420px; overflow-y: auto; margin-bottom: .8rem; }
.bubble { padding: .6rem .8rem; border-radius: 10px; background: #f0f3f6; max-width: 90%; white-space: pre-wrap; }
.bubble.mine { background: #e3eefc; align-self: flex-end; }
.bubble.internal { background: #fff5e0; border: 1px dashed #e0c07a; }
.bubble .meta { font-size: .76rem; color: var(--muted); margin-bottom: .2rem; white-space: normal; }

/* Kanban */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: .7rem; overflow-x: auto; padding-bottom: .5rem; }
.col { background: #eef1f4; border-radius: var(--radius); padding: .6rem; min-height: 120px; }
.col h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 .5rem; display: flex; justify-content: space-between; }
.ticket { display: block; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem; margin-bottom: .5rem; text-decoration: none; color: inherit; font-size: .87rem; box-shadow: var(--shadow); }
.ticket:hover { border-color: #9cc3e6; }
.ticket .ref { font-weight: 700; color: var(--brand); }
.ticket.overdue { border-left: 4px solid var(--bad); }
.ticket.soon { border-left: 4px solid var(--warn); }
.ticket.urgent .ref::after { content: " URGENT"; color: var(--accent); font-size: .7rem; }

/* Tabs */
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .5rem .85rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; font-size: .93rem; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Report editor */
.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 1000px) { .editor { grid-template-columns: 1fr; } }
.editor textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88rem; min-height: 70vh; line-height: 1.45; }
.preview { background: #fff; border: 1px solid var(--line); border-radius: 7px; padding: 1rem 1.3rem; min-height: 70vh; max-height: 80vh; overflow-y: auto; font-family: Georgia, "Times New Roman", serif; }
.preview table { border-collapse: collapse; width: 100%; margin: .6rem 0; }
.preview td, .preview th { border: 1px solid #ccd; padding: .3rem .5rem; vertical-align: top; }
.preview blockquote { border-left: 3px solid #ccd; margin: .6rem 0; padding: .1rem .8rem; color: #555; }

/* Dictation panel */
.dictation { border: 1px solid #c9d8ea; background: #f4f8fd; border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1rem; }
.dictation .live { min-height: 2.4rem; background: #fff; border: 1px dashed #b8c8da; border-radius: 6px; padding: .4rem .6rem; font-size: .93rem; margin: .5rem 0; white-space: pre-wrap; }
.dictation .live .interim { color: var(--muted); font-style: italic; }
.rec-dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; background: #aab3bd; }
.recording .rec-dot { background: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.dictation select { width: auto; }

/* Public site */
.hero { background: linear-gradient(135deg, var(--brand) 0%, #1b4d73 60%, var(--brand-2) 100%); color: #fff; }
.hero .inner { max-width: 1280px; margin: 0 auto; padding: 3.5rem 1rem 3rem; }
.hero h1 { color: #fff; font-size: 2.3rem; max-width: 820px; }
.hero p { font-size: 1.12rem; max-width: 720px; color: #dbe6f2; }
.hero .btn { background: #fff; color: var(--brand); border-color: #fff; }
.hero .btn.secondary { background: transparent; color: #fff; }
.feature h3 { margin-top: 0; }
.feature .icon { font-size: 1.6rem; }
.price { font-weight: 700; color: var(--brand); white-space: nowrap; }
.steps { counter-reset: s; list-style: none; padding: 0; display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.steps li { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; position: relative; padding-top: 2.4rem; }
.steps li::before { counter-increment: s; content: counter(s); position: absolute; top: .7rem; left: 1rem; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--brand-2); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: .85rem; }

.spinner { display: inline-block; width: .9rem; height: .9rem; border: 2px solid #c7d0da; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* Language switch and brand mark */
.langswitch { display: inline-flex; align-items: center; gap: 0; margin-left: .3rem; color: #9fb4c9; }
.langswitch .linklike { padding: .3rem .4rem; font-size: .85rem; font-weight: 600; letter-spacing: .03em; }
.langswitch .linklike.active { color: #fff; text-decoration: underline; text-underline-offset: 4px; }
.brand .mark { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 6px; background: #fff; color: var(--accent); font-size: .95rem; }
.hero .expert { font-weight: 600; color: #fff; margin-top: .4rem; }
