:root {
    color-scheme: light;
    --bg: #e7edf2;
    --card: #ffffff;
    --ink: #152033;
    --muted: #5c6b7c;
    --line: #d9e2ea;
    --brand: #0f6e56;
    --brand-dark: #0b5543;
    --side: #101820;
    --danger: #b42318;
    --warn: #9a6700;
    --ok: #067647;
    --shadow: 0 18px 40px rgba(16, 24, 32, 0.06);
}

* { box-sizing: border-box; }

html, body { overflow-x: hidden; }
body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 100% 0, rgba(15, 110, 86, 0.08), transparent 28%),
        var(--bg);
    color: var(--ink);
    font-family: Vazirmatn, Tahoma, sans-serif;
}

a { color: inherit; }
button, input, select, textarea { font: inherit; }

.app {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.side {
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding: 22px 16px;
    background: var(--side);
    color: white;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: var(--brand);
    font-weight: 700;
}

.brand strong { display: block; font-size: 15px; }
.brand small { display: block; margin-top: 2px; color: #b7c3d1; font-size: 12px; }

.nav { display: grid; gap: 6px; }
.nav a, .side-logout button {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 0 12px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #d5dee8;
    text-decoration: none;
    cursor: pointer;
}

.nav a.is-active, .nav a:hover, .side-logout button:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.side-logout { margin-top: auto; }
.side-logout button { width: 100%; }

.workspace { min-width: 0; }
.page, .bare { width: min(1240px, calc(100% - 40px)); margin: 28px auto 56px; }
.bare { min-height: 100vh; }

.row-between h2 { margin: 0; }
.page-head, .row-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.page-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--brand-dark);
    font-size: 12px;
    font-weight: 700;
}

h1 { margin: 0; font-size: 30px; letter-spacing: -0.03em; }
h2 { margin: 0 0 14px; font-size: 17px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 22px 0; }
.card, .panel, .client {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.card { padding: 16px 18px; }
.card b { display: block; margin-top: 8px; font-size: 30px; }
.panel { padding: 18px; margin-top: 16px; }
.table-block { margin-top: 16px; }
.table-block h2 { margin-bottom: 10px; }
.table-wrap {
    overflow-x: hidden;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.table-wrap.no-scroll { overflow: hidden; }
.panel .table-wrap {
    border: 0;
    border-radius: 12px;
    box-shadow: none;
}
.notice-panel .row-between {
    margin-bottom: 14px;
    align-items: flex-start;
}
.notice-panel .row-between .muted { margin: 4px 0 0; }
.notice-empty {
    margin: 0;
    padding: 18px;
    border: 1px dashed var(--line);
    border-radius: 14px;
    background: #f8fafb;
    text-align: center;
}
.notice-empty p { margin: 0; }
.notice-list { display: grid; gap: 10px; }
.notice-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #f8fafb;
    border-inline-start-width: 4px;
}
.notice-item.is-info { border-inline-start-color: #3b82f6; }
.notice-item.is-success { border-inline-start-color: var(--ok); }
.notice-item.is-warning { border-inline-start-color: var(--warn); }
.notice-item.is-error { border-inline-start-color: var(--danger); }
.notice-item__body { min-width: 0; flex: 1; }
.notice-item__body strong { display: block; font-size: 15px; }
.notice-item__body p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.7;
    white-space: pre-wrap;
}
.notice-item__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.notice-item .row-actions { flex-shrink: 0; }
.data {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
}
.data th, .data td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.data th {
    background: #f6f8fa;
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
}
.data tbody tr:last-child td { border-bottom: 0; }
.data tbody tr:hover { background: #f7fbf9; }
.data a { color: var(--brand-dark); font-weight: 700; text-decoration: none; }
.col-actions { width: 1%; }
.col-actions .row-actions { justify-content: flex-start; }
.tag {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: #f6f8fa;
    font-size: 13px;
    font-weight: 700;
}
.tag-info { background: #eff6ff; color: #1d4ed8; }
.tag-ok { background: #e9f7f1; color: var(--ok); }
.tag-warn { background: #fff6e8; color: var(--warn); }
.tag-off { background: #fdeceb; color: var(--danger); }

.data-fit { table-layout: fixed; font-size: 13px; }
.data-fit th, .data-fit td {
    padding: 10px 6px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.data-fit .col-row { width: 3rem; }
.data-fit .col-name { width: 11%; }
.row-index {
    display: inline-grid;
    place-items: center;
    min-width: 1.75rem;
    height: 1.75rem;
    padding: 0 6px;
    border-radius: 8px;
    background: #f4f7f8;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}
.data-fit .col-domain { width: 15%; }
.data-fit .col-license { width: 8%; }
.data-fit .col-key { width: 9%; }
.data-fit .col-link { width: 4.25rem; }
.data-fit .col-date { width: 10%; }
.data-fit .col-money { width: 12%; }
.data-fit .col-seen { width: 16%; }
.data-fit .col-actions { width: 4.25rem; }
.data-fit .col-message { width: 34%; }
.data-fit .col-kind { width: 13%; }
.data-fit .col-tools { width: 8.5rem; }
.data-fit .message-cell { white-space: normal; }
.data-fit .message-cell .muted {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.data-fit td:has(.icon-btn) { overflow: visible; }
.data-fit .is-center { text-align: center; }
.data-fit .tag {
    max-width: 100%;
    min-height: 24px;
    padding: 0 8px;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.link-mark {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    vertical-align: middle;
}
.link-mark svg { width: 22px; height: 22px; }
.link-mark circle { fill: currentColor; }
.link-mark path {
    fill: none;
    stroke: white;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.link-mark.is-on { color: var(--ok); }
.link-mark.is-off { color: var(--danger); }
.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: #eef3f6;
    color: var(--ink);
    text-decoration: none;
    cursor: pointer;
}
.icon-btn:hover { background: #e3eaef; color: var(--brand-dark); }
.icon-btn.is-danger { background: #fdeceb; color: var(--danger); }
.icon-btn.is-danger:hover { background: #f8d4d1; }
.icon-btn svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 16px;
    border-radius: 12px;
    border: 0;
    gap: 8px;
    text-decoration: none;
    cursor: pointer;
    font-weight: 650;
}
.btn-primary { background: var(--brand); color: white; box-shadow: 0 1px 2px rgba(15, 110, 86, 0.28); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-back {
    background: white;
    color: var(--ink);
    border: 1px solid var(--line);
    box-shadow: 0 1px 2px rgba(16, 24, 32, 0.04);
}
.btn-back:hover { border-color: #b7c9bf; color: var(--brand-dark); background: #f7fbf9; }
.btn-ghost, .btn-on-dark { background: #eef3f6; color: var(--ink); }
.btn-on-dark { background: rgba(255, 255, 255, 0.14); color: white; }
.btn-danger { background: #fdeceb; color: var(--danger); }
.btn-ok { background: #e7f6ef; color: var(--ok); }
.btn svg {
    width: 1rem;
    height: 1rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-danger-text { background: white; color: var(--danger); border: 1px solid #f3c4c0; }

.filters { display: flex; gap: 8px; margin: 18px 0; }
.filter-card {
    margin: 18px 0 16px;
    padding: 16px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px 14px;
}
.filter-card label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}
.filter-card input,
.filter-card select {
    width: 100%;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f8fafb;
    padding: 0 12px;
    color: var(--ink);
    font-weight: 500;
}
.filter-card input:focus,
.filter-card select:focus {
    outline: none;
    border-color: #8fbfb0;
    background: white;
    box-shadow: 0 0 0 3px rgba(15, 110, 86, 0.12);
}
.filter-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}
.filters input, .filters select, .field input, .field select, .field textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: white;
    border-radius: 12px;
    padding: 11px 12px;
    color: var(--ink);
}
.field textarea { min-height: 120px; resize: vertical; }
.filters input { min-width: 260px; }
.filters select { width: auto; min-width: 160px; }

.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.row-actions form { margin: 0; }
.you {
    display: inline-flex;
    margin-inline-start: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #e9f7f1;
    color: var(--ok);
    font-size: 12px;
    font-weight: 700;
}
.client {
    display: grid;
    gap: 14px;
    padding: 16px;
    text-decoration: none;
}
.client:hover { border-color: #b7d7cb; }
.client-id { display: grid; gap: 4px; }
.client-id span, .signal small { color: var(--muted); font-size: 13px; }

.signals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.signal {
    display: grid;
    gap: 4px;
    min-height: 92px;
    padding: 12px;
    border-radius: 14px;
    background: #f6f8fa;
}
.signal span { color: var(--muted); font-size: 12px; }
.signal strong { font-size: 16px; }
.signal-ok { background: #e9f7f1; }
.signal-ok strong { color: var(--ok); }
.signal-warn { background: #fff6e8; }
.signal-warn strong { color: var(--warn); }
.signal-off { background: #fdeceb; }
.signal-off strong { color: var(--danger); }

.license {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    border-radius: 14px;
    background: var(--side);
    color: white;
    direction: ltr;
}
.license { padding: 8px 8px 8px 18px; }
.license code { font-size: 20px; letter-spacing: 0.04em; }
.license-rotate {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
}
.license-card__split {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}
.license-card__split form { margin: 0; }
.copy-note { margin: 10px 0 0; color: var(--ok); font-weight: 700; }
.copy-btn.is-copied { background: #e7f6ef; color: var(--ok); }
.actions, .panel form + form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.panel form.sms-test {
    display: grid;
    gap: 8px;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}
.sms-test label { font-weight: 650; }
.sms-test__row { display: flex; gap: 8px; align-items: center; }
.sms-test__row input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--line);
    background: white;
    border-radius: 12px;
    padding: 11px 12px;
    color: var(--ink);
}
.sms-test__row .btn { flex-shrink: 0; }
.confirm { display: flex; align-items: center; gap: 8px; }
jdp-container, jdp-container * { font-family: Vazirmatn, Tahoma, sans-serif; }

.facts { display: grid; gap: 10px; margin: 0; }
.facts div { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }

.modules { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.modules label, .modules div {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
}
.modules div::before { content: ""; width: 8px; height: 8px; border-radius: 99px; background: #c5d0da; }
.modules div.is-on { background: #e9f7f1; border-color: #b7e4d2; }
.modules div.is-on::before { background: var(--ok); }

.flash, .errors { margin-bottom: 16px; padding: 12px 14px; border-radius: 12px; }
.flash { background: #e7f6ef; color: var(--ok); }
.errors { background: #fdeceb; color: var(--danger); }
.fields { display: grid; gap: 14px; }
.field label, .field-label { display: block; margin-bottom: 6px; font-weight: 650; }
.field input::placeholder, .field textarea::placeholder { color: #93a0ae; }
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(15, 110, 86, 0.16);
}

.editor { display: grid; gap: 14px; }
.editor .panel { margin-top: 0; }
.editor-split {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
    gap: 14px;
    align-items: start;
}
.stack { display: grid; gap: 14px; }
.bill-card {
    background:
        linear-gradient(180deg, rgba(15, 110, 86, 0.06), transparent 120px),
        var(--card);
}
.pick-list { max-height: 240px; overflow: auto; margin-top: 8px; }
.field [data-pick-search] {
    margin-top: 0;
}
.tone-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tone-grid-3 { grid-template-columns: repeat(3, 1fr); }
.tone-card {
    display: grid;
    place-items: center;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f8fafb;
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.tone-card input { position: absolute; opacity: 0; pointer-events: none; }
.tone-card:has(input:checked) {
    border-color: transparent;
    box-shadow: inset 0 0 0 2px currentColor;
}
.tone-card.is-info:has(input:checked) { background: #eff6ff; color: #1d4ed8; }
.tone-card.is-success:has(input:checked) { background: #ecfdf3; color: #067647; }
.tone-card.is-warning:has(input:checked) { background: #fffbeb; color: #9a6700; }
.tone-card.is-error:has(input:checked) { background: #fef2f2; color: #b42318; }
.tone-card:not([class*="is-"]):has(input:checked) { background: white; color: var(--brand-dark); border-color: #8fbfb0; }
.segment {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    border-radius: 14px;
    background: #eef3f6;
}
.segment label {
    display: grid;
    place-items: center;
    min-height: 40px;
    border-radius: 11px;
    color: var(--muted);
    font-weight: 700;
    cursor: pointer;
}
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment label:has(input:checked) {
    background: white;
    color: var(--brand-dark);
    box-shadow: 0 1px 2px rgba(16, 24, 32, 0.08);
}
.segment.segment-3 { grid-template-columns: repeat(3, 1fr); }
.segment.segment-4 { grid-template-columns: repeat(4, 1fr); }
.money {
    display: flex;
    align-items: stretch;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: white;
}
.field .money input {
    min-width: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    font-variant-numeric: tabular-nums;
}
.field .money input:focus { border-color: transparent; box-shadow: none; }
.money:focus-within {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(15, 110, 86, 0.16);
}
.money-suffix {
    display: grid;
    place-items: center;
    min-width: 4.75rem;
    padding: 0 12px;
    border-inline-start: 1px solid var(--line);
    background: #f4f7f8;
    color: var(--brand-dark);
    font-size: 13px;
    font-weight: 700;
}
.period-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.period-choices .choice { min-height: 52px; padding: 12px 14px; }
.section-head { margin-bottom: 16px; }
.section-head h2 { margin-bottom: 4px; }
.section-head p { margin: 0; }
.editor .field + .field, .editor .choices + .field, .editor .grid-2 { margin-top: 14px; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice {
    display: grid;
    gap: 2px;
    padding: 14px 14px 14px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    cursor: pointer;
}
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { font-weight: 700; }
.choice small { color: var(--muted); }
.choice:has(input:checked) {
    border-color: var(--brand);
    background: #e9f7f1;
    box-shadow: inset 0 0 0 1px var(--brand);
}
.choice:has(input[value="suspended"]:checked) {
    border-color: var(--danger);
    background: #fdeceb;
    box-shadow: inset 0 0 0 1px var(--danger);
}

.modules input {
    width: 1rem;
    height: 1rem;
    margin: 0;
    padding: 0;
    accent-color: var(--brand);
}
.modules label { cursor: pointer; font-weight: 600; }
.modules label:has(input:checked) {
    background: #e9f7f1;
    border-color: #8dceb6;
}

.form-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 4px 0 12px;
}

.login-wrap { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: min(440px, 100%); padding: 28px; }
.login-card h1 { margin-bottom: 8px; }
.login-card form { display: grid; gap: 14px; margin-top: 18px; }

.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; }
.list { display: grid; gap: 10px; }
.list a { display: flex; justify-content: space-between; gap: 12px; text-decoration: none; }
.list a:hover { color: var(--brand-dark); }

@media (max-width: 1200px) {
    .table-wrap:has(.data-stack) {
        overflow: visible;
        background: transparent;
        border: 0;
        box-shadow: none;
    }
    .data-stack {
        display: block;
        font-size: 14px;
    }
    .data-stack colgroup,
    .data-stack thead { display: none; }
    .data-stack tbody { display: grid; gap: 10px; }
    .data-stack tr {
        display: block;
        overflow: hidden;
        background: var(--card);
        border: 1px solid var(--line);
        border-radius: 16px;
        box-shadow: var(--shadow);
    }
    .data-stack td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        width: auto;
        padding: 11px 14px;
        overflow: visible;
        white-space: normal;
        text-overflow: unset;
        text-align: start;
    }
    .data-stack td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        color: var(--muted);
        font-size: 12px;
        font-weight: 650;
    }
    .data-stack td:not([data-label]) { display: block; text-align: center; }
    .data-stack td:not([data-label])::before { content: none; }
    .data-stack td:last-child { border-bottom: 0; }
    .data-stack .tag,
    .data-stack a { max-width: none; overflow: visible; text-overflow: unset; }
    .data-stack tr:hover { background: var(--card); }
    .data-stack .row-actions { justify-content: flex-end; }
}

@media (max-width: 1100px) {
    .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .side { gap: 16px; }
    .nav { grid-template-columns: repeat(2, 1fr); }
    .side-logout { margin-top: 0; }
    .cards, .grid-2, .modules, .signals, .choices, .editor-split, .period-choices, .segment.segment-3, .segment.segment-4, .tone-grid-3 { grid-template-columns: 1fr; }
    .user-row { align-items: flex-start; flex-direction: column; }
    .form-footer { justify-content: stretch; }
    .form-footer .btn { flex: 1; }
    .page-head, .row-between, .list a { align-items: flex-start; flex-direction: column; }
    .notice-item { flex-direction: column; }
    .filters { flex-direction: column; }
    .filters input, .filters select { width: 100%; min-width: 0; }
    .filter-grid { grid-template-columns: 1fr; }
}
