:root {
    --bg: #f5f7f8;
    --ink: #16202a;
    --muted: #667383;
    --line: #dce3e8;
    --panel: #ffffff;
    --teal: #0f766e;
    --teal-dark: #0b5f59;
    --blue: #27548a;
    --amber: #b7791f;
    --red: #b42318;
    --green: #14703a;
    --shadow: 0 18px 42px rgba(22, 32, 42, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    line-height: 1.35;
}

a {
    color: inherit;
    text-decoration: none;
}

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

.brand-mark {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    border-radius: 8px;
    background: var(--ink);
    color: #fff;
    font-weight: 900;
    letter-spacing: 0;
}

.brand-mark.small {
    width: 32px;
    height: 32px;
    font-size: 12px;
}

.menu-toggle {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 90;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 74px;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 8px;
    background: var(--ink);
    color: #fff;
    box-shadow: 0 14px 34px rgba(22, 32, 42, .22);
    cursor: pointer;
    font-size: 13px;
    font-weight: 900;
}

.menu-toggle.open,
.menu-toggle:hover {
    background: var(--teal-dark);
}

.floating-menu {
    position: fixed;
    right: 14px;
    bottom: 62px;
    z-index: 89;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 198px;
    gap: 5px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .97);
    box-shadow: 0 18px 42px rgba(22, 32, 42, .18);
    backdrop-filter: blur(14px);
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px) scale(.98);
    transition: opacity .16s ease, transform .16s ease;
}

.floating-menu.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.floating-menu a,
.floating-menu button,
.logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 6px 7px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}

.floating-menu a.active,
.floating-menu a:hover,
.floating-menu button:hover,
.logout:hover {
    background: #eaf0f2;
    color: var(--ink);
}

.floating-menu button {
    color: var(--teal-dark);
}

.floating-menu .logout {
    grid-column: 1 / -1;
    color: var(--red);
}

.layout {
    width: min(1180px, calc(100% - 32px));
    margin: 12px auto 36px;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 12px;
}

.page-head h1,
.person-card h1 {
    margin: 0;
    font-size: clamp(24px, 3vw, 38px);
    line-height: 1.02;
    letter-spacing: 0;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--teal);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.demo-sales-note {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
    align-items: center;
    margin: 0 0 12px;
    padding: 12px;
    border: 1px solid #b8d9ca;
    border-radius: 8px;
    background: #eef8f3;
}

.demo-sales-note strong {
    font-size: 15px;
}

.demo-sales-note p {
    grid-column: 1;
    margin: 0;
    color: var(--muted);
}

.demo-sales-note a {
    grid-column: 2;
    grid-row: 1 / span 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 7px 10px;
    border-radius: 6px;
    background: var(--green);
    color: #fff;
    font-weight: 900;
}

.demo-sales-note a:hover {
    background: #0f5f30;
}

.metric-grid article,
.panel,
.person-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.metric-grid article {
    padding: 12px;
}

.metric-grid span,
.muted,
small {
    color: var(--muted);
}

.metric-grid strong {
    display: block;
    margin-top: 5px;
    font-size: 26px;
    line-height: 1;
}

.split {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(320px, .8fr);
    gap: 12px;
}

.dashboard-split {
    grid-template-columns: minmax(0, 1fr) 300px;
    align-items: start;
}

.dashboard-split .panel {
    min-height: 118px;
}

.dashboard-split .panel:first-child {
    min-width: 0;
}

.dashboard-split .panel:first-child .table-wrap {
    max-height: 420px;
    overflow: auto;
}

.dashboard-split .panel:last-child {
    position: sticky;
    top: 12px;
}

.panel {
    padding: 14px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

h2,
h3,
p {
    margin-top: 0;
}

h2 {
    margin-bottom: 10px;
    font-size: 18px;
}

.primary,
.secondary,
.ghost,
.tiny {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
    text-align: center;
}

.tiny {
    min-height: 26px;
    padding: 4px 7px;
    font-size: 11px;
}

.primary {
    background: var(--teal);
    color: #fff;
}

.primary:hover {
    background: var(--teal-dark);
}

.secondary,
.ghost,
.tiny {
    background: #fff;
    color: var(--ink);
    border-color: var(--line);
}

.secondary:hover,
.ghost:hover,
.tiny:hover {
    background: #eef3f5;
}

.danger-action {
    color: var(--red);
    border-color: #f0c3bd;
}

.danger-action:hover {
    background: #fff0ee;
}

.lawyer-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid #19b26b;
    border-radius: 6px;
    background: #19a765;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 900;
    text-align: center;
}

.lawyer-submit:hover {
    background: #118653;
}

.wide {
    width: 100%;
}

.button-row,
.send-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.send-row {
    margin-top: 10px;
}

.alert {
    margin-bottom: 10px;
    padding: 9px 11px;
    border-radius: 8px;
    font-weight: 700;
}

.alert.success {
    background: #e8f7ef;
    color: var(--green);
    border: 1px solid #b9e5cb;
}

.alert.danger {
    background: #fff0ee;
    color: var(--red);
    border: 1px solid #f5c5bd;
}

.call-screen {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(340px, .85fr);
    gap: 12px;
}

.person-card {
    padding: 16px;
    min-height: 420px;
}

.person-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

.role,
.source {
    display: inline-flex;
    padding: 5px 8px;
    border-radius: 6px;
    background: #e9f2f1;
    color: var(--teal-dark);
    font-size: 12px;
    font-weight: 900;
}

.source {
    background: #f4ead9;
    color: var(--amber);
}

.phone-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 14px 0;
    padding: 12px;
    border-radius: 8px;
    background: #17202a;
    color: #fff;
}

.phone-box span {
    font-size: clamp(20px, 3vw, 30px);
    font-weight: 900;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.phone-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.phone-actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-height: 31px;
    padding: 7px 9px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font-size: 12px;
    font-weight: 900;
}

.phone-actions a:hover {
    background: #eaf0f2;
}

.details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
}

.details div {
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fafcfd;
}

.details dt {
    color: var(--muted);
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
}

.details dd {
    margin: 3px 0 0;
    font-weight: 800;
}

.last-note {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.last-note p {
    margin: 7px 0 0;
}

.lawyer-share-screen {
    align-items: start;
}

.lawyer-grid {
    display: grid;
    gap: 8px;
    margin-bottom: 10px;
}

.whatsapp-button {
    display: grid;
    gap: 3px;
    padding: 10px;
    border: 1px solid #b9e5cb;
    border-radius: 8px;
    background: #e8f7ef;
    color: var(--ink);
}

.whatsapp-button:hover {
    background: #d8f2e5;
}

.whatsapp-button strong {
    color: #0f6b3b;
    font-size: 15px;
}

.whatsapp-button span {
    color: var(--muted);
    font-weight: 800;
}

.message-preview {
    margin-top: 12px;
}

.message-preview textarea {
    background: #f8fbfc;
}

.small-help {
    font-size: 12px;
}

.sync-status {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    margin: 0 0 10px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #e9f2f1;
    color: var(--teal-dark);
    font-size: 11px;
    font-weight: 900;
}

.sync-status.syncing {
    background: #fff4df;
    color: var(--amber);
}

.sync-status.warn {
    background: #fff0ee;
    color: var(--red);
}

.sync-status.ok {
    background: #e9f2f1;
    color: var(--teal-dark);
}

.stack {
    display: grid;
    gap: 10px;
}

label {
    display: grid;
    gap: 5px;
}

label span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cbd5dc;
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    padding: 8px 9px;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(15, 118, 110, .18);
    border-color: var(--teal);
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 660px;
}

th {
    text-align: left;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

th,
td {
    padding: 7px 8px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

td small {
    display: block;
    margin-top: 1px;
    font-size: 11px;
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    min-width: 126px;
}

.row-actions form {
    margin: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 2px 7px;
    border-radius: 999px;
    background: #edf1f4;
    color: var(--ink);
    font-size: 11px;
    font-weight: 900;
}

.badge.good {
    background: #e3f4eb;
    color: var(--green);
}

.badge.bad {
    background: #fdebe8;
    color: var(--red);
}

.badge.process {
    background: #e8eff8;
    color: var(--blue);
}

.badge.wait {
    background: #fff4df;
    color: var(--amber);
}

.next-card {
    display: grid;
    gap: 6px;
}

.start-call-button {
    background: var(--green);
}

.start-call-button:hover {
    background: #0f5f30;
}

.next-card h3 {
    margin: 0;
    font-size: 22px;
}

.empty,
.empty-state {
    color: var(--muted);
}

.empty-state {
    text-align: center;
    padding: 28px 14px;
}

.settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
    gap: 12px;
    align-items: start;
}

.settings-form-grid {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.settings-panel {
    display: grid;
    gap: 10px;
    align-content: start;
}

.settings-panel h2 {
    margin-bottom: 0;
}

.settings-save-panel {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: #101820;
    color: #fff;
}

.settings-save-panel h2 {
    margin-bottom: 3px;
}

.settings-save-panel .muted {
    color: #c8d4dc;
    margin: 0;
}

.settings-save-panel .primary {
    min-width: 160px;
    background: var(--green);
}

.settings-save-panel .primary:hover {
    background: #0f5f30;
}

.repeat-group {
    display: grid;
    gap: 7px;
}

.repeat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.repeat-head span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.repeat-head .tiny {
    background: #e8f7ef;
    border-color: #b9e5cb;
    color: var(--green);
}

.repeat-head .tiny:hover {
    background: #d8f2e5;
}

.repeat-list {
    display: grid;
    gap: 6px;
}

.repeat-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    align-items: center;
    padding: 6px;
    border: 1px solid #e4ebef;
    border-radius: 8px;
    background: #f8fbfc;
}

.repeat-row.lawyer-row {
    grid-template-columns: minmax(0, 1fr) minmax(130px, .82fr) auto;
}

.repeat-row input {
    min-height: 32px;
}

.repeat-remove {
    white-space: nowrap;
}

.edit-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.danger-zone {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.detail-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    padding: 8px;
    border-radius: 8px;
    background: #f2f6f7;
}

.detail-strip span {
    color: var(--muted);
}

.field-pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.check {
    display: flex;
    align-items: center;
    gap: 7px;
    padding-top: 22px;
}

.check input {
    width: 16px;
    height: 16px;
}

.cron-url {
    display: block;
    margin: 10px 0;
    padding: 8px;
    border-radius: 6px;
    background: #101820;
    color: #dbeafe;
    overflow-wrap: anywhere;
}

.pwa-status {
    margin-top: 10px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f6faf9;
    color: var(--teal-dark);
    font-weight: 800;
}

.toolbar-form {
    display: flex;
    align-items: end;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #f4f7f9 0%, #eaf1ef 52%, #f7f1e7 100%);
}

.login-shell {
    width: min(390px, calc(100% - 28px));
}

.login-panel {
    padding: 22px;
    background: rgba(255, 255, 255, .92);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.login-panel h1 {
    margin-bottom: 6px;
    font-size: 26px;
}

.login-panel p {
    color: var(--muted);
}

.login-meta {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.login-guide {
    margin-top: 10px;
    color: var(--ink);
    font-size: 12px;
}

.login-guide summary {
    cursor: pointer;
    color: var(--teal-dark);
    font-weight: 900;
}

.login-guide ol {
    margin: 9px 0 0;
    padding-left: 18px;
    color: var(--muted);
}

.login-guide li + li {
    margin-top: 6px;
}

@media (max-width: 900px) {
    body {
        padding-bottom: 76px;
    }

    .menu-toggle {
        right: 12px;
        bottom: 12px;
        min-width: 66px;
        min-height: 36px;
        padding: 7px 10px;
        font-size: 12px;
    }

    .floating-menu {
        right: 12px;
        bottom: 56px;
        width: 184px;
        gap: 4px;
        padding: 7px;
    }

    .floating-menu a,
    .floating-menu button {
        min-height: 29px;
        padding: 5px 6px;
        font-size: 11px;
    }

    .page-head,
    .split,
    .call-screen,
    .settings-grid,
    .settings-form-grid,
    .edit-grid,
    .metric-grid,
    .field-pair,
    .repeat-row,
    .repeat-row.lawyer-row {
        grid-template-columns: 1fr;
    }

    .page-head {
        align-items: stretch;
        flex-direction: column;
    }

    .settings-save-panel {
        align-items: stretch;
        flex-direction: column;
    }

    .settings-save-panel .primary {
        width: 100%;
    }

    .demo-sales-note {
        grid-template-columns: 1fr;
    }

    .demo-sales-note a {
        grid-column: auto;
        grid-row: auto;
        width: 100%;
    }

    .metric-grid {
        display: grid;
    }

    .dashboard-split .panel:last-child {
        position: static;
    }

    .dashboard-split .panel:first-child .table-wrap {
        max-height: 320px;
    }

    .details {
        grid-template-columns: 1fr;
    }

    .phone-box {
        align-items: flex-start;
        flex-direction: column;
    }

    .phone-actions {
        justify-content: flex-start;
        width: 100%;
    }
}

@media (max-width: 560px) {
    .layout {
        width: min(100% - 18px, 1180px);
        margin-top: 12px;
    }

    .panel,
    .person-card {
        padding: 12px;
    }

    .phone-box span {
        font-size: 22px;
    }

    .button-row,
    .toolbar-form,
    .send-row {
        align-items: stretch;
        flex-direction: column;
    }

    .button-row > *,
    .toolbar-form > *,
    .send-row > * {
        width: 100%;
    }
}
