:root {
    color-scheme: light;
    font-family: "Instrument Sans", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    color: #18233a;
    background: #f4f6fb;
    --surface: #fff;
    --soft: #f7f8fc;
    --line: #dce2ed;
    --text: #18233a;
    --muted: #55627a;
    --accent: #2949bb;
    --accent-hover: #20398f;
    --accent-soft: #e9efff;
    --success: #165d44;
    --success-soft: #e8f6ef;
    --warn: #85452a;
    --warn-soft: #fff2e9;
    --radius: .85rem;
    --small-radius: .52rem;
    --shadow: 0 1px 2px rgb(27 43 83 / 5%), 0 8px 26px rgb(27 43 83 / 4%);
}
* { box-sizing: border-box; }
body { margin: 0; line-height: 1.5; }
[hidden] { display: none !important; }
a { color: var(--accent); text-underline-offset: .2em; }
a:hover { color: var(--accent-hover); }
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.wrap { width: min(100% - 3rem, 83rem); margin: 0 auto; }
.top .wrap, nav, .history-heading, .page-heading, .filter, .campaign-controls {
    display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
}
.top .wrap { min-height: 4.5rem; gap: .75rem 2rem; padding: .75rem 0; }
.brand { font-weight: 760; letter-spacing: -.03em; font-size: 1.08rem; }
nav { gap: .25rem; }
nav a {
    padding: .48rem .75rem;
    border-radius: var(--small-radius);
    color: var(--muted);
    text-decoration: none;
    font-size: .9rem;
    font-weight: 620;
}
nav a:hover { background: var(--soft); }
nav a[aria-current="page"] { color: var(--accent-hover); background: var(--accent-soft); }
main { padding: 2.15rem 0 4rem; }
h1, h2, h3 { line-height: 1.18; letter-spacing: -.025em; }
h1 { margin: 0 0 1.2rem; font-size: clamp(1.9rem, 4.3vw, 2.7rem); font-weight: 760; }
h2 { margin: 0 0 1rem; font-size: 1.35rem; }
.page-heading { justify-content: space-between; margin-bottom: 1.25rem; }
.page-heading h1, .page-heading p { margin: 0; }
.timing-mode {
    padding: .34rem .66rem;
    background: var(--accent-soft);
    border-radius: var(--small-radius);
    color: var(--accent-hover);
    font-size: .8rem;
    font-weight: 650;
}
.timing-mode:empty { display: none; }
.timing-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 1rem 1.5rem; }
.timing-fields label { margin: 0; }
.timing-fields input { display: block; width: 100%; margin: .4rem 0 .25rem; border: 1px solid #b8c3d5; border-radius: var(--small-radius); padding: .62rem .72rem; background: var(--surface); color: var(--text); }
.timing-fields select { display: block; width: 100%; margin-top: .4rem; }
.timing-fields .hint { display: block; font-weight: normal; }
.card {
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.45rem;
    margin: 1.1rem 0;
}
.login { max-width: 29rem; margin: 3rem auto; }
label { display: block; font-weight: 650; margin: .6rem 0 .3rem; }
.hint, .muted, .sender { color: var(--muted); }
.hint { margin: 0 0 .6rem; }
input, textarea, select, button { font: inherit; }
input[type="password"], textarea, select {
    border: 1px solid #b8c3d5;
    border-radius: var(--small-radius);
    padding: .62rem .72rem;
    background: var(--surface);
    color: var(--text);
}
input[type="password"], textarea { width: 100%; }
textarea { display: block; resize: vertical; margin-bottom: 1rem; }
input[type="file"] { display: block; max-width: 100%; margin: .35rem 0 1rem; }
input[type="radio"], input[type="checkbox"] { accent-color: var(--accent); }
button, input::file-selector-button {
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: var(--small-radius);
    padding: .53rem .85rem;
    color: white;
    background: var(--accent);
    font-weight: 650;
}
button:hover { background: var(--accent-hover); }
button:disabled { cursor: default; opacity: .55; }
.button-secondary, input::file-selector-button {
    color: var(--accent-hover);
    background: var(--surface);
    border-color: var(--line);
}
.button-secondary:hover, input::file-selector-button:hover { background: var(--accent-soft); }
:focus-visible { outline: 3px solid #647ce6; outline-offset: 2px; }

.dialogue-draft summary { font-weight: 650; }
.dialogue-draft {
    border: 1px solid #e8c5ad; background: var(--warn-soft);
    border-radius: var(--small-radius); padding: 1rem;
}
.dialogue-draft h3 { margin-top: 0; }
.variant-dialog {
    width: min(38rem, 100% - 2rem); max-height: calc(100dvh - 2rem); overflow: auto;
    padding: 1.45rem; border: 1px solid var(--line); border-radius: var(--radius);
    color: inherit; background: var(--surface);
}
.variant-dialog::backdrop { background: rgb(21 34 67 / 46%); }
.variant-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.notice { color: var(--warn); }
.notice:empty { display: none; }
pre {
    font: inherit; white-space: pre-wrap; overflow-wrap: anywhere;
    background: var(--soft); padding: .85rem 1rem; border-radius: var(--small-radius);
}
.counts { display: flex; flex-wrap: wrap; gap: .75rem; }
.counts div { background: var(--soft); padding: .55rem .85rem; border-radius: var(--small-radius); }
.counts dd { margin: 0; font-weight: 720; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: .72rem .78rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); }
.latest { white-space: pre-wrap; overflow-wrap: anywhere; }
.filter label { margin: 0; }
.campaign-controls:not(:empty) {
    margin-bottom: 1rem; padding: .8rem 1rem; gap: .55rem .85rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.campaign-controls p { margin: 0; }
.campaign-controls .notice { font-size: .88rem; }
.dialogs-card { padding: 0; }
.list-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: .55rem; padding: .8rem 1rem;
}
.list-toolbar .notice { margin: 0; font-size: .85rem; }
.list-toolbar { flex-wrap: wrap; gap: 1rem; }
.stage-shortcuts { display: flex; flex-wrap: wrap; gap: 1rem; }
.stage-shortcuts form { margin: 0; }
.stage-shortcuts a { white-space: nowrap; font-weight: 600; }
.stage-shortcuts a[aria-current="page"] { text-decoration-thickness: 2px; }
.filter label { color: var(--muted); font-size: .86rem; }
.dialogs-table { min-width: 60rem; }
.dialogs-table th {
    padding: .66rem 1rem; background: var(--soft); border-top: 1px solid var(--line);
    font-size: .78rem; font-weight: 700; white-space: nowrap;
}
.dialogs-table td { padding: .95rem 1rem; font-size: .9rem; }
.dialogs-table tbody tr:last-child td { border-bottom: 0; }
.dialogs-table tbody tr:hover { background: #fcfdff; }
.dialogs-table td:nth-child(4) { width: 39%; }
.contact-link { font-weight: 680; }
.stage {
    display: inline-block; padding: .22rem .55rem; border-radius: 10rem;
    color: #364564; background: #edf0f7; font-size: .78rem; font-weight: 700; white-space: nowrap;
}
.stage.agreed { color: var(--success); background: var(--success-soft); }
.stage.declined { color: var(--warn); background: var(--warn-soft); }
.stage-detail { display: block; color: var(--muted); margin-top: .35rem; overflow-wrap: anywhere; }
.dialog-state { min-width: 7rem; color: var(--muted); overflow-wrap: anywhere; }
.dialogs-table button {
    color: var(--accent-hover); background: var(--surface); border-color: var(--line); font-size: .78rem;
}
.dialogs-table button:hover { background: var(--accent-soft); }
.dialogs-table .empty-table { padding: 2.1rem 1rem; color: var(--muted); text-align: center; }
.recent-messages, .messages { list-style: none; padding: 0; margin: 0; }
.recent-messages { display: grid; gap: .42rem; }
.recent-messages li, .message {
    padding: .55rem .7rem; background: var(--soft); border-radius: var(--small-radius); overflow-wrap: anywhere;
}
.recent-messages strong { font-size: .76rem; color: var(--muted); }
.recent-messages p { margin: .15rem 0 0; white-space: pre-wrap; }
.recent-messages .outgoing, .message.outgoing { background: var(--accent-soft); }
.history-heading { justify-content: space-between; margin-bottom: 1rem; }
.history-heading h2 { margin: 0; }
.message { margin: .65rem 0; padding: .75rem .95rem; max-width: 45rem; }
.message p { white-space: pre-wrap; margin: .35rem 0 0; }
time { margin-left: .7rem; font-size: .83rem; color: var(--muted); }
@media (max-width: 54rem) {
    .dialogs-table, .dialogs-table tbody, .dialogs-table th { display: block; }
    .dialogs-table { min-width: 0; }
    .dialogs-table thead { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); }
    .dialogs-table tr { display: grid; padding: .8rem 1rem; border-top: 1px solid var(--line); }
    .dialogs-table td, .dialogs-table td:nth-child(4) { display: block; width: auto; border: 0; padding: .33rem 0; }
    .dialogs-table td[data-label]::before {
        content: attr(data-label); display: block; margin-bottom: .22rem;
        color: var(--muted); font-size: .72rem; font-weight: 700;
    }
    .dialogs-table td:empty { display: none; }
}
@media (max-width: 38rem) {
    .wrap { width: calc(100% - 1.5rem); }
    .top .wrap { display: block; }
    nav { margin-top: .55rem; gap: .15rem; }
    nav a { padding: .42rem .5rem; font-size: .82rem; }
    main { padding-top: 1.35rem; }
    .card:not(.dialogs-card) { padding: 1rem; }
}

