:root {
    --bg-start: #f5f7fa;
    --bg-end: #c3cfe2;
    --card-bg: #ffffff;
    --text-main: #2d3f52;
    --text-soft: #6f8192;
    --line: rgba(44, 62, 80, 0.12);
    --primary: #3498db;
    --primary-dark: #2b83bf;
    --success: #2ecc71;
    --danger: #e74c3c;
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.08);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Heebo", "Segoe UI", Tahoma, sans-serif;
    color: var(--text-main);
    background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-end) 100%);
    min-height: 100vh;
}

.page {
    width: min(1200px, 94vw);
    margin: 0 auto;
    padding: 1.25rem 0 2rem;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 120;
    width: min(1200px, 94vw);
    margin: 0 auto;
    padding: 0.9rem 0;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.8rem;
    backdrop-filter: blur(8px);
    background: rgba(245, 247, 250, 0.92);
}

.topbar-nav {
    justify-self: center;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.45rem;
}

.section-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid #d4dbe6;
    padding: 0.42rem 0.9rem;
    font-weight: 700;
    text-decoration: none;
    color: #4a6075;
    background: #f9fbfd;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.section-tab:hover {
    background: #eff5fb;
}

.section-tab.is-active {
    border-color: transparent;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.topbar-actions {
    justify-self: end;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.45rem;
}

.topbar-actions .btn-outline.is-active {
    border-color: transparent;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.topbar-actions form {
    margin: 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    text-decoration: none;
    color: var(--text-main);
}

.brand strong {
    display: block;
    font-size: 1rem;
}

.brand small {
    color: var(--text-soft);
    font-size: 0.78rem;
}

.brand-mark {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #64b8f1);
    box-shadow: 0 6px 12px rgba(52, 152, 219, 0.35);
}

.panel {
    background: var(--card-bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
}

.center-wrap {
    min-height: calc(100vh - 5rem);
    display: grid;
    place-items: center;
}

.login-card {
    width: min(430px, 94vw);
    padding: 2rem;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.75s ease forwards;
}

.login-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-header h1,
.sticky-header h1,
.settings-card h1 {
    margin: 0;
    font-size: clamp(1.8rem, 1.2rem + 2vw, 2.4rem);
    display: inline-block;
    position: relative;
}

.login-header h1::after,
.sticky-header h1::after,
.settings-card h1::after {
    content: "";
    position: absolute;
    bottom: -6px;
    left: 0;
    width: 0;
    height: 3px;
    border-radius: 3px;
    background: var(--primary);
    animation: expandWidth 0.9s ease forwards 0.35s;
}

.muted {
    color: var(--text-soft);
    margin: 0.3rem 0 0;
}

.form-stack,
.settings-form {
    display: grid;
    gap: 0.95rem;
}

.form-group {
    display: grid;
    gap: 0.45rem;
}

label {
    font-size: 0.9rem;
    color: var(--text-main);
}

input,
select {
    width: 100%;
    border: 2px solid #e0e4ea;
    background: #f8f9fb;
    border-radius: 10px;
    padding: 0.72rem 0.82rem;
    font: inherit;
    transition: all 0.25s ease;
    color: var(--text-main);
}

input:focus,
select:focus,
.search-box:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 2px 15px rgba(52, 152, 219, 0.18);
    background: #fff;
}

.btn {
    border: none;
    border-radius: 999px;
    padding: 0.6rem 1.05rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:hover {
    transform: translateY(-2px);
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 8px 18px rgba(52, 152, 219, 0.3);
}

.btn-outline {
    color: var(--text-main);
    background: #fff;
    border: 1px solid #ccd3de;
}

.btn-outline:hover {
    background: #f3f5f8;
}

.login-button {
    margin-top: 0.5rem;
    border-radius: 10px;
    padding-block: 0.74rem;
}

.alert {
    margin-bottom: 1rem;
    border-radius: 10px;
    border: 1px solid rgba(231, 76, 60, 0.35);
    background: rgba(231, 76, 60, 0.11);
    color: #b13325;
    padding: 0.7rem 0.8rem;
}

.demo-box {
    margin-bottom: 1rem;
    border-radius: 10px;
    border: 1px solid rgba(52, 152, 219, 0.35);
    background: rgba(52, 152, 219, 0.1);
    color: #1f5274;
    padding: 0.7rem 0.8rem;
}

.demo-box p {
    margin: 0.3rem 0 0;
}

.dashboard-shell {
    display: grid;
    gap: 1rem;
}

.sticky-header {
    position: sticky;
    top: 4.4rem;
    z-index: 100;
    padding: 1rem;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.stats-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.stat-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.58rem;
    border-radius: 999px;
    background: #eef4fb;
    color: #355c78;
    border: 1px solid #d6e5f4;
    font-size: 0.83rem;
}

.ext-chip-row {
    margin-top: 0.65rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.ext-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.22rem 0.62rem;
    border-radius: 999px;
    background: rgba(52, 152, 219, 0.12);
    color: #24618c;
    border: 1px solid rgba(52, 152, 219, 0.28);
    font-size: 0.82rem;
}

.flash-banner {
    padding: 0.7rem 0.9rem;
}

.flash-success {
    background: rgba(46, 204, 113, 0.12);
    border-color: rgba(46, 204, 113, 0.38);
    color: #1e8a4d;
}

.flash-error {
    background: rgba(231, 76, 60, 0.11);
    border-color: rgba(231, 76, 60, 0.35);
    color: #b3392e;
}

.demo-banner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.72rem 0.9rem;
    background: rgba(241, 196, 15, 0.14);
    border-color: rgba(241, 196, 15, 0.38);
    color: #8a6708;
}

.tabs-wrap {
    padding: 1rem;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tab {
    border: 1px solid #d4dbe6;
    border-radius: 999px;
    padding: 0.45rem 0.95rem;
    font-family: inherit;
    font-weight: 600;
    color: #4a6075;
    background: #f9fbfd;
    cursor: pointer;
    transition: all 0.25s ease;
}

.tab:hover {
    background: #eff5fb;
}

.tab.is-active {
    border-color: transparent;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.tab-panel {
    display: none;
    animation: fadeIn 0.28s ease;
}

.tab-panel.is-active {
    display: block;
}

.dial-settings-banner {
    border: 1px solid #dbe4ee;
    background: #f8fbff;
    border-radius: 13px;
    padding: 0.72rem 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 0.85rem;
}

.danger-text {
    color: var(--danger);
    font-weight: 700;
}

.prefix-chip {
    display: inline-flex;
    align-items: center;
    margin-inline-start: 0.45rem;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    border: 1px solid #ccdff1;
    background: #edf5fc;
    color: #2a628b;
    font-size: 0.78rem;
}

.contacts-tools {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.search-container,
.upload-form {
    padding: 0.85rem;
    border: 1px solid #dde4ee;
    border-radius: 14px;
    background: #f8fbff;
}

.search-container {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    align-items: center;
}

.search-box {
    border-radius: 999px;
    padding: 0.75rem 1rem;
    border: 2px solid #dce3ec;
    background: #fff;
}

.btn-search {
    min-width: 96px;
}

.upload-form {
    display: grid;
    gap: 0.45rem;
}

.upload-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    align-items: center;
}

.contacts-grid,
.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 0.9rem;
}

.contact-card {
    background: #f3f4f6;
    border: 1px solid #e2e5ea;
    border-radius: 18px;
    padding: 1.05rem;
    text-align: center;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
}

.contact-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 24px rgba(0, 0, 0, 0.1);
}

.contact-title {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    color: #2f4256;
    margin-bottom: 0.5rem;
}

.contact-line {
    margin: 0.2rem 0;
    color: #6a7785;
    font-size: 1.25rem;
    font-weight: 600;
}

.phone-list {
    margin-top: 0.75rem;
    display: grid;
    gap: 0.45rem;
}

.dial-now-form {
    margin: 0;
}

.phone-row-btn {
    width: 100%;
    border: none;
    border-radius: 14px;
    padding: 0.55rem 0.8rem;
    background: #e8eaee;
    color: #556677;
    font-size: 1.22rem;
    font-family: inherit;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.22s ease;
}

.phone-row-btn:hover {
    transform: translateY(-1px);
    background: #dfe4ea;
}

.phone-row-btn:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.phone-number {
    margin-inline: auto;
}

.phone-icon {
    opacity: 0.7;
}

.dial-now-form.is-loading .phone-row-btn {
    background: #d3ecfb;
    color: #1f5f8c;
}

.item-card {
    background: #fff;
    border: 1px solid #e4eaf1;
    border-radius: 14px;
    padding: 1rem;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
}

.item-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.09);
}

.item-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.84rem;
    color: var(--text-soft);
    gap: 0.6rem;
}

.item-card h3 {
    margin: 0.45rem 0 0;
}

.folder-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    border: 1px solid #cddcec;
    background: #eff6fd;
    color: #386689;
}

.usage-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.8rem;
    margin-bottom: 0.95rem;
}

.calls-filter-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.65rem;
    padding: 0.85rem;
    border: 1px solid #dce5f0;
    border-radius: 14px;
    background: #f8fbff;
    margin-bottom: 0.9rem;
}

.calls-filter-form label {
    display: grid;
    gap: 0.35rem;
    font-size: 0.86rem;
    color: #4b5f73;
}

.calls-filter-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.45rem;
}

.calls-clean-header {
    border: 1px solid #dce5f0;
    border-radius: 14px;
    background: #f8fbff;
    padding: 0.85rem 0.95rem;
    margin-bottom: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
}

.calls-quick-filter {
    border: 1px solid #dce5f0;
    border-radius: 14px;
    background: #ffffff;
    padding: 0.75rem;
    margin-bottom: 0.9rem;
    display: grid;
    gap: 0.7rem;
}

.calls-quick-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 0.55rem;
}

.calls-quick-field {
    display: grid;
    gap: 0.28rem;
}

.calls-quick-field span {
    font-size: 0.77rem;
    color: #607286;
    font-weight: 600;
}

.calls-quick-field input,
.calls-quick-field select {
    padding: 0.5rem 0.6rem;
    border-radius: 8px;
    background: #f7f9fc;
    border-width: 1.5px;
    font-size: 0.92rem;
}

.calls-quick-days input {
    max-width: 90px;
}

.calls-quick-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
    padding-top: 0.2rem;
}

.usage-alert {
    border: 1px solid #f0d998;
    background: #fff8e5;
    color: #8a6a11;
    border-radius: 12px;
    padding: 0.65rem 0.85rem;
    display: grid;
    gap: 0.2rem;
    margin-bottom: 0.85rem;
}

.usage-alert-danger {
    border-color: #f2c4be;
    background: #fdeeee;
    color: #a33d32;
}

.usage-chart-card {
    border: 1px solid #dce6f1;
    border-radius: 14px;
    background: #ffffff;
    padding: 0.8rem;
    margin-bottom: 0.9rem;
}

.usage-chart-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.usage-chart-bars {
    height: 160px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(18px, 1fr));
    align-items: end;
    gap: 0.25rem;
}

.usage-bar-wrap {
    display: grid;
    gap: 0.2rem;
    align-items: end;
    justify-items: center;
}

.usage-bar {
    width: 100%;
    min-height: 2px;
    border-radius: 6px 6px 2px 2px;
    background: linear-gradient(180deg, #2f9ee0 0%, #256fbb 100%);
}

.usage-bar-label {
    font-size: 0.64rem;
    color: #5d7084;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    line-height: 1;
}

.direction-breakdown {
    display: grid;
    gap: 0.55rem;
}

.direction-row {
    display: grid;
    gap: 0.25rem;
}

.direction-row-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.84rem;
    color: #4d6277;
}

.direction-row-track {
    height: 10px;
    border-radius: 999px;
    background: #e5edf6;
    overflow: hidden;
}

.direction-row-fill {
    height: 100%;
    border-radius: inherit;
    min-width: 2px;
}

.direction-row-fill.direction-outbound {
    background: linear-gradient(90deg, #4ea4de, #2d7bbd);
}

.direction-row-fill.direction-inbound {
    background: linear-gradient(90deg, #7bc98c, #4f9c5f);
}

.direction-row-fill.direction-internal {
    background: linear-gradient(90deg, #b19bd8, #896db9);
}

.reports-filter-form {
    border: 1px solid #dce5f0;
    border-radius: 14px;
    background: #f8fbff;
    padding: 0.9rem;
    margin-bottom: 0.9rem;
    display: grid;
    gap: 0.75rem;
}

.reports-filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.65rem;
}

.reports-filter-field {
    display: grid;
    gap: 0.35rem;
}

.reports-filter-field span {
    font-size: 0.85rem;
    color: #4b5f73;
}

.reports-filter-field input,
.reports-filter-field select {
    width: 100%;
}

.reports-filter-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    border-top: 1px solid #dbe4ef;
    padding-top: 0.7rem;
}

.summary-card {
    border: 1px solid #dce6f1;
    border-radius: 14px;
    background: #f8fbff;
    padding: 0.85rem 0.95rem;
}

.summary-label {
    margin: 0;
    font-size: 0.84rem;
    color: #617386;
}

.summary-card h3 {
    margin: 0.28rem 0 0;
    font-size: 1.55rem;
    color: #2f4458;
}

.progress-track {
    width: 100%;
    height: 9px;
    border-radius: 999px;
    background: #e5edf6;
    overflow: hidden;
    margin-top: 0.45rem;
}

.progress-value {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #2c9ee0, #44b98e);
}

.direction-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    font-size: 0.76rem;
    border: 1px solid #d7dfe9;
    color: #5b6877;
    background: #f4f7fb;
}

.direction-outbound {
    border-color: #c5dcf2;
    color: #22608b;
    background: #e9f4fd;
}

.direction-inbound {
    border-color: #cbeccf;
    color: #2f7c3e;
    background: #ebf9ed;
}

.direction-internal {
    border-color: #e1d8ef;
    color: #66508e;
    background: #f5f0fc;
}

.call-state {
    margin: 0.4rem 0 0;
    font-size: 0.9rem;
    font-weight: 700;
}

.call-state.answered {
    color: #228a4f;
}

.call-state.missed {
    color: #bf4436;
}

audio {
    width: 100%;
    margin-top: 0.7rem;
}

.empty {
    margin: 0.4rem 0 0;
    color: var(--text-soft);
}

.settings-shell {
    min-height: calc(100vh - 8rem);
    display: grid;
    place-items: center;
}

.settings-card {
    width: min(520px, 94vw);
    padding: 1.4rem;
}

.settings-form .btn {
    width: 100%;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.92rem;
}

.checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.diagnostics-shell {
    display: grid;
    gap: 1rem;
}

.diag-header-actions {
    margin-top: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.diag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.85rem;
}

.diag-card {
    padding: 0.9rem;
    border: 1px solid #dce5ef;
    background: #ffffff;
}

.diag-card.diag-ok {
    border-color: #cae9d4;
    background: #f4fcf7;
}

.diag-card.diag-warn {
    border-color: #f0dda7;
    background: #fffaf0;
}

.diag-card.diag-error {
    border-color: #f0c7c2;
    background: #fff4f3;
}

.diag-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.diag-card h3 {
    margin: 0;
}

.diag-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.52rem;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.diag-badge-ok {
    color: #246b3f;
    background: #e5f6ec;
    border-color: #c2e6d0;
}

.diag-badge-warn {
    color: #8d6b1b;
    background: #fff2d3;
    border-color: #f0d38b;
}

.diag-badge-error {
    color: #a2392d;
    background: #fde9e7;
    border-color: #f4c8c2;
}

.diag-message {
    margin: 0.45rem 0 0;
    font-weight: 600;
    color: #344b5f;
}

.diag-details {
    margin: 0.45rem 0 0;
    border: 1px dashed #d5dfe8;
    border-radius: 8px;
    padding: 0.45rem 0.55rem;
    background: #ffffff;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.78rem;
    color: #5a6d80;
    white-space: pre-wrap;
    word-break: break-word;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes expandWidth {
    to {
        width: 100%;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 900px) {
    .sticky-header {
        top: 6.9rem;
    }

    .header-row {
        flex-direction: column;
    }

    .stats-inline {
        justify-content: flex-start;
    }

    .contacts-tools {
        grid-template-columns: 1fr;
    }

    .search-container,
    .upload-row {
        grid-template-columns: 1fr;
    }

    .dial-settings-banner {
        flex-direction: column;
        align-items: stretch;
    }

    .calls-quick-grid {
        grid-template-columns: repeat(2, minmax(140px, 1fr));
    }

    .calls-clean-header {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 640px) {
    .topbar,
    .page {
        width: min(1200px, 96vw);
    }

    .topbar {
        grid-template-columns: 1fr;
        justify-items: stretch;
        gap: 0.55rem;
    }

    .brand {
        justify-content: space-between;
    }

    .topbar-nav {
        justify-content: flex-start;
    }

    .topbar-actions {
        justify-self: stretch;
        justify-content: flex-start;
    }

    .calls-quick-grid {
        grid-template-columns: 1fr;
    }

    .calls-quick-days input {
        max-width: 100%;
    }

    .login-card {
        padding: 1.35rem;
    }

    .contact-title {
        font-size: 1.65rem;
    }

    .contact-line,
    .phone-row-btn {
        font-size: 1.08rem;
    }

    .item-card {
        padding: 0.85rem;
    }
}
