body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    line-height: 1.3;
    background: linear-gradient(180deg, #eaf6fb 0%, #d8eef8 100%);
    color: #1f2937;
}

.app-shell,
.dashboard-page,
.patient-page {
    min-height: 100vh;
}

.dashboard-page,
.patient-page {
    padding-bottom: 20px;
}

/* --------------------------------
   DASHBOARD
-------------------------------- */

.top-bar-modern {
    display: grid;
    grid-template-columns: 200px 1fr auto;
    gap: 16px;
    align-items: center;
}

.brand-box {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.brand-logo {
    background: #fff;
    border: 1px solid #d5e3ec;
    border-radius: 14px;
    padding: 14px 18px;
    font-size: 2rem;
    font-weight: 700;
    color: #2b6f94;
    box-shadow: 0 8px 20px rgba(38, 87, 115, 0.08);
    text-align: center;
}

.brand-subtitle {
    font-size: 0.78rem;
    color: #5b7180;
    text-align: center;
}

.main-create-action {
    display: flex;
    justify-content: center;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

/* --------------------------------
   BUTTONS
-------------------------------- */

.btn-primary-modern,
.btn-soft,
.btn-row-action,
.btn-danger-soft {
    border-radius: 10px;
    transition: 0.2s ease;
    font-weight: 600;
    font-size: 0.88rem;
}

.btn-primary-modern {
    background: linear-gradient(135deg, #2489c5, #43a7e2);
    color: #fff;
    border: none;
    padding: 10px 20px;
    min-width: 200px;
    font-size: 0.96rem;
    box-shadow: 0 8px 16px rgba(40, 126, 176, 0.18);
}

.btn-primary-modern:hover {
    transform: translateY(-1px);
    color: #fff;
}

.btn-soft {
    background: #fff;
    color: #2c4858;
    border: 1px solid #d7e5ed;
    padding: 8px 12px;
    box-shadow: 0 3px 10px rgba(40, 78, 101, 0.05);
}

.btn-soft:hover {
    background: #f8fcfe;
    color: #16394d;
    transform: translateY(-1px);
}

.btn-danger-soft {
    background: #fff;
    color: #9e2d2d;
    border: 1px solid #edc5c5;
    padding: 8px 12px;
    font-weight: 700;
}

.btn-danger-soft:hover {
    background: #fff5f5;
    color: #862020;
}

.btn-row-action {
    background: #f3f8fb;
    border: 1px solid #d5e3ec;
    color: #2c5c78;
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 0.9rem;
    line-height: 1;
}

.btn-row-action:hover {
    background: #e7f3fa;
}

.btn-tall {
    min-height: 44px;
}

.btn-save-patient {
    min-width: 130px;
    min-height: 38px;
    padding: 8px 14px;
    font-size: 0.9rem;
}

/* --------------------------------
   CARDS / PANELS
-------------------------------- */

.modern-card,
.side-panel,
.patient-main-card {
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(208, 227, 236, 0.95);
    border-radius: 16px;
    box-shadow: 0 10px 24px rgba(41, 79, 102, 0.08);
}

.modern-card {
    padding: 14px;
}

.side-panel {
    padding: 12px;
}

.patient-main-card {
    overflow: hidden;
}

.filter-panel,
.patient-left-panel,
.patient-right-panel {
    min-height: 100%;
}

.card-heading {
    font-size: 0.98rem;
    font-weight: 700;
    color: #1f4256;
    margin-bottom: 12px;
}

.section-card {
    padding-bottom: 10px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #17384d;
    line-height: 1.2;
}

.section-subtitle {
    font-size: 0.78rem;
    color: #65808f;
    margin-top: 2px;
}

.section-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --------------------------------
   FORMS
-------------------------------- */

.form-label,
.left-field label,
.gdpr-title,
.right-panel-title,
.financial-title,
.tab-block-title,
.visit-col label {
    display: block;
    font-size: 0.76rem;
    font-weight: 700;
    color: #355263;
    margin-bottom: 4px;
    line-height: 1.2;
}

.left-field {
    margin-bottom: 10px;
}

.modern-input {
    border-radius: 10px;
    border: 1px solid #d7e4ec;
    min-height: 36px;
    padding: 6px 10px;
    font-size: 0.84rem;
    background: #fff;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

textarea.modern-input {
    padding-top: 8px;
    padding-bottom: 8px;
}

.modern-input:focus {
    border-color: #73b8de;
    box-shadow: 0 0 0 0.15rem rgba(67, 167, 226, 0.12);
}

.quick-search {
    min-width: 280px;
}

.checkbox-line {
    display: flex;
    gap: 6px;
    align-items: center;
    font-size: 0.8rem;
    color: #38586c;
}

input[type="checkbox"] {
    transform: scale(0.95);
}

/* --------------------------------
   TABLES
-------------------------------- */

.table-shell {
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid #d9e7ef;
    background: #fff;
}

.table-wrapper {
    overflow: auto;
}

.patients-table-wrapper,
.followups-table-wrapper {
    max-height: 600px;
}

.modern-table {
    white-space: nowrap;
    font-size: 0.82rem;
}

.modern-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: linear-gradient(180deg, #edf7fc 0%, #e2f1f8 100%);
    color: #1d4258;
    font-weight: 700;
    border-bottom: 1px solid #d6e5ee;
    padding: 9px 8px;
    font-size: 0.78rem;
}

.modern-table td {
    padding: 8px;
    border-color: #edf2f6;
    background: #fff;
    color: #253746;
    font-size: 0.8rem;
}

.modern-table tbody tr:nth-child(even) td {
    background: #fbfdfe;
}

.modern-table tbody tr:hover td {
    background: #eef8fd;
}

/* --------------------------------
   PATIENT PAGE
-------------------------------- */

.patient-page {
    background: linear-gradient(180deg, #edf6fb 0%, #deedf7 100%);
}

.patient-topbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
    align-items: center;
}

.patient-topbar-left,
.patient-topbar-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.patient-topbar-right {
    justify-content: flex-end;
}

.account-bar {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    padding: 8px 18px;
    border-bottom: 1px solid #d9e7ef;
    background: #ffffff;
}

.account-identity,
.account-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.account-name {
    color: #1d4258;
    font-weight: 700;
}

.account-role {
    padding: 3px 8px;
    border-radius: 999px;
    background: #e5f3fa;
    color: #2d607d;
    font-size: 0.75rem;
    font-weight: 700;
}

.account-actions form {
    margin: 0;
}

.auth-page,
.account-page {
    min-height: 100vh;
    padding: 32px 16px;
    background: linear-gradient(180deg, #edf6fb 0%, #deedf7 100%);
}

.account-page {
    position: relative;
}

.account-page-back {
    position: absolute;
    top: 32px;
    left: 32px;
}

.auth-page {
    display: grid;
    place-items: center;
}

.auth-card,
.account-form-card,
.users-card {
    width: min(100%, 1120px);
    margin: 0 auto;
    padding: 28px;
    border: 1px solid #d9e7ef;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 18px 45px rgba(29, 66, 88, 0.12);
}

.auth-card {
    width: min(100%, 420px);
}

.account-form-card {
    width: min(100%, 620px);
}

.account-form-card-wide {
    width: min(100%, 900px);
}

.auth-brand {
    color: #1d4258;
    font-size: 1.7rem;
    font-weight: 800;
}

.auth-subtitle,
.account-page-header p {
    margin: 4px 0 22px;
    color: #668091;
}

.auth-form,
.account-form {
    display: grid;
    gap: 18px;
}

.auth-remember {
    margin: 0;
}

.account-page-header {
    display: flex;
    gap: 18px;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-back-row {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 18px;
}

.account-page-header h1 {
    margin: 0;
    color: #1d4258;
    font-size: 1.45rem;
    font-weight: 800;
}

.account-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.account-form-submit {
    grid-column: 1 / -1;
}

.required-mark {
    color: #b12d2d;
}

.account-profile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
    width: min(100%, 1180px);
    margin: 0 auto;
}

.account-profile-grid .account-form-card {
    width: 100%;
}

.account-visits-card {
    grid-column: 1 / -1;
    width: 100% !important;
    max-width: 100%;
}

.account-visit-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.account-visit-summary > div {
    display: grid;
    gap: 5px;
    padding: 14px;
    border: 1px solid #dce9f0;
    border-radius: 12px;
    background: #f5fafc;
}

.account-visit-summary span {
    color: #668091;
    font-size: 0.78rem;
    font-weight: 700;
}

.account-visit-summary strong {
    color: #1d4258;
    font-size: 1.25rem;
}

.account-visit-filters {
    display: flex;
    gap: 10px;
    align-items: end;
    margin-bottom: 20px;
}

.account-visit-patient-filter {
    flex: 1;
}

.account-visits-loading {
    padding: 20px;
    color: #668091;
    text-align: center;
}

.account-visits-card .modern-table td:nth-child(3) {
    max-width: 420px;
    white-space: pre-line;
}

.account-visits-pagination {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: flex-end;
    margin-top: 16px;
    color: #456273;
    font-size: 0.85rem;
    font-weight: 700;
}

.account-page-header h2,
.account-future-card h2 {
    margin: 0;
    color: #1d4258;
    font-size: 1.2rem;
    font-weight: 800;
}

.account-future-card {
    display: flex;
    grid-column: 1 / -1;
    gap: 18px;
    align-items: center;
    justify-content: space-between;
    padding: 22px 26px;
    border: 1px dashed #a8c7d8;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.72);
}

.account-future-card p {
    margin: 6px 0 0;
    color: #668091;
}

.account-coming-soon {
    padding: 5px 10px;
    border-radius: 999px;
    background: #e5f3fa;
    color: #2d607d;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.user-row-actions {
    display: flex;
    gap: 7px;
    align-items: center;
    justify-content: flex-end;
}

.user-row-actions form {
    margin: 0;
}

@media (max-width: 720px) {
    .account-bar,
    .account-page-header {
        align-items: stretch;
        flex-direction: column;
    }

    .account-page-back {
        position: static;
        margin: 0 auto 16px;
        width: min(100%, 1180px);
    }

    .account-actions {
        flex-wrap: wrap;
    }

    .account-form-grid {
        grid-template-columns: 1fr;
    }

    .account-profile-grid {
        grid-template-columns: 1fr;
    }

    .account-visit-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .account-visit-filters {
        align-items: stretch;
        flex-direction: column;
    }

    .account-form-grid > div:empty {
        display: none;
    }
}

.blacklist-toggle {
    display: inline-flex;
    gap: 7px;
    align-items: center;
    margin: 0;
    padding: 7px 10px;
    border: 1px solid #edc5c5;
    border-radius: 10px;
    background: #fff5f5;
    color: #862020;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
}

.blacklist-toggle input {
    margin: 0;
}

.archive-patient-dialog {
    width: min(460px, calc(100vw - 32px));
    padding: 24px;
    border: 1px solid #edc5c5;
    border-radius: 16px;
    background: #ffffff;
    color: #253746;
    box-shadow: 0 24px 70px rgba(22, 57, 77, 0.25);
}

.archive-patient-dialog::backdrop {
    background: rgba(22, 40, 54, 0.55);
}

.archive-patient-dialog-title {
    margin-bottom: 10px;
    color: #862020;
    font-size: 1.15rem;
    font-weight: 800;
}

.archive-patient-dialog p {
    margin-bottom: 20px;
    line-height: 1.55;
}

.archive-patient-dialog-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.patient-balance-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.patient-balance-label,
.save-status-label {
    font-weight: 700;
    font-size: 0.82rem;
    color: #244558;
}

.patient-balance-box {
    min-width: 90px;
    min-height: 36px;
    background: #fff;
    border: 1px solid #d7e4ec;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.84rem;
    color: #274a60;
    box-shadow: 0 4px 12px rgba(40, 78, 101, 0.05);
}

.patient-balance-box.has-balance {
    background: #ffddb0;
    border-color: #f0bf7b;
    color: #7a4711;
}

.attention-box {
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 12px;
    text-align: center;
    font-weight: 800;
    font-size: 0.82rem;
    border: 1px solid #d7e4ec;
}

.attention-yes {
    background: #ffe1e1;
    color: #a02626;
    border-color: #f3b4b4;
}

.attention-no {
    background: #ffffff;
    color: #49606f;
}

.left-grid.two-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.left-grid.phone-grid {
    display: grid;
    grid-template-columns: 1fr 80px 30px;
    gap: 6px;
    align-items: end;
}

.small-field {
    min-width: 0;
}

.left-checkboxes {
    display: flex;
    align-items: center;
    justify-content: center;
}

.align-end {
    align-items: end;
}

.left-section {
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e7eef4;
}

.left-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
}

.left-section-title {
    font-size: 0.84rem;
    font-weight: 800;
    color: #23485d;
    margin-bottom: 8px;
}

.highlight-box {
    border: 1px solid #dce8ef;
    background: #f8fbfd;
    border-radius: 10px;
    padding: 8px 10px;
}

.patient-left-panel {
    overflow: auto;
}

.patient-tabs {
    display: flex;
    gap: 2px;
    padding: 10px 10px 0 10px;
    background: linear-gradient(180deg, #eef7fc 0%, #e2f0f8 100%);
    border-bottom: 1px solid #dce8ef;
}

.patient-tab {
    border: 0;
    font-family: inherit;
    text-decoration: none;
    color: #3c5a6c;
    font-weight: 700;
    font-size: 0.82rem;
    padding: 9px 14px;
    border-radius: 10px 10px 0 0;
    background: transparent;
    cursor: pointer;
}

.patient-tab:hover {
    color: #16394d;
    background: rgba(255, 255, 255, 0.65);
}

.patient-tab.active {
    background: #ffffff;
    color: #1d4258;
    border: 1px solid #dce8ef;
    border-bottom: 1px solid #ffffff;
}

.patient-tab-content {
    padding: 14px;
    background: #ffffff;
    min-height: 700px;
}

/* --------------------------------
   GDPR
-------------------------------- */

.gdpr-box {
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 10px;
    border: 2px solid #dce8ef;
    background: #f9fcfe;
}

.gdpr-title {
    font-size: 0.8rem;
    font-weight: 800;
    color: #355263;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.gdpr-status {
    font-size: 0.74rem;
    font-weight: 700;
}

.gdpr-ok {
    border-color: #bde5c8;
    background: #f3fbf6;
}

.gdpr-ok .gdpr-status {
    color: #2f7d4f;
}

.gdpr-missing {
    border-color: #f2b6b6;
    background: #fff3f3;
}

.gdpr-missing .gdpr-status {
    color: #b03a3a;
}

/* --------------------------------
   SAVE STATUS
-------------------------------- */

.save-status-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 12px;
}

.save-status-chip {
    min-width: 160px;
    min-height: 34px;
    border-radius: 999px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.78rem;
    border: 1px solid #d7e4ec;
    background: #fff;
    color: #355263;
    box-shadow: 0 4px 12px rgba(40, 78, 101, 0.05);
}

.save-status-chip.is-saved {
    background: #f3fbf6;
    border-color: #bde5c8;
    color: #2f7d4f;
}

.save-status-chip.is-dirty {
    background: #fff8e8;
    border-color: #f1ddb0;
    color: #9a6a13;
}

.save-status-chip.is-saving {
    background: #eef7ff;
    border-color: #bfdcf5;
    color: #21618c;
}

.save-status-chip.is-error {
    background: #fff3f3;
    border-color: #f2b6b6;
    color: #b03a3a;
}

.save-success-pulse {
    box-shadow: 0 0 0 0 rgba(47, 125, 79, 0.4);
    animation: savePulse 0.5s ease;
}

@keyframes savePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

/* --------------------------------
   TAB BLOCKS
-------------------------------- */

.tab-block,
.tab-large-table-card,
.history-card,
.visit-row,
.financial-box {
    background: #f9fcfe;
    border: 1px solid #deebf2;
    border-radius: 14px;
}

.tab-block,
.tab-large-table-card,
.history-card,
.visit-row,
.financial-box,
.work-log-box {
    padding: 10px;
}

.tab-block {
    height: 100%;
}

.tab-textarea {
    resize: vertical;
    min-height: 110px;
    font-size: 0.82rem;
}

.three-col-head,
.three-col-body {
    display: grid;
    grid-template-columns: 120px 1fr 1fr;
    gap: 10px;
}

.three-col-head {
    font-weight: 700;
    font-size: 0.78rem;
    color: #355263;
    margin-bottom: 8px;
}

.three-col-cell.small-cell {
    max-width: 120px;
}

/* --------------------------------
   RIGHT PANEL
-------------------------------- */

.right-panel-title,
.financial-title,
.tab-block-title {
    font-size: 0.82rem;
}

.work-log-box {
    min-height: 500px;
    max-height: 500px;
    overflow: auto;
    border: 1px solid #deebf2;
    border-radius: 14px;
    background: #fbfdff;
    margin-bottom: 12px;
}

.work-log-line {
    font-size: 0.78rem;
    color: #253746;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #edf2f6;
}

.financial-row {
    display: grid;
    grid-template-columns: 20px 1fr;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.financial-input {
    min-height: 34px;
}

/* --------------------------------
   ISTORIKO TAB
-------------------------------- */

.istoriko-tab {
    min-height: 100%;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    align-items: start;
}

.history-card {
    min-height: 100%;
}

.history-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.history-card-title {
    font-size: 0.84rem;
    font-weight: 700;
    color: #355263;
}

.history-card-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.history-card textarea {
    min-height: 340px;
    resize: vertical;
    font-size: 0.82rem;
}

/* --------------------------------
   EPISKepseis TAB
-------------------------------- */

.episkepseis-tab {
    min-height: 100%;
}

.visits-toolbar {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 12px;
    position: sticky;
    top: 8px;
    z-index: 30;
    padding: 8px;
    border-bottom: 1px solid rgba(215, 228, 236, 0.9);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(8px);
}

.visits-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.visit-grid {
    display: grid;
    grid-template-columns: 112px 150px 110px minmax(280px, 1fr) 245px;
    gap: 10px;
    align-items: start;
}

.visit-summary-text {
    min-height: 82px;
    resize: vertical;
    font-size: 0.8rem;
}

.visit-followup-row {
    display: grid;
    grid-template-columns: 150px 105px minmax(180px, 0.8fr) minmax(260px, 1.4fr) auto;
    gap: 10px;
    align-items: end;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e1ebf1;
}

.visit-followup-field textarea {
    min-height: 38px;
    resize: vertical;
}

.visit-delete-action {
    display: flex;
    justify-content: flex-end;
    align-items: end;
    min-width: max-content;
}

.followup-inline {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: end;
}

.followup-inline.single-col {
    grid-template-columns: 1fr;
}

.followup-checkbox {
    margin-bottom: 6px;
    white-space: nowrap;
}

.finance-grid-head,
.finance-grid-body {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.finance-grid-head {
    margin-bottom: 4px;
}

.finance-grid-head span {
    font-size: 0.74rem;
    font-weight: 700;
    color: #355263;
    text-align: center;
}

.finance-bottom-row {
    margin-top: 8px;
    display: flex;
    justify-content: flex-end;
}

/* --------------------------------
   RESPONSIVE
-------------------------------- */

@media (max-width: 1600px) {
    .top-bar-modern {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .brand-box,
    .main-create-action,
    .header-actions {
        justify-content: center;
    }

    .header-actions {
        display: flex;
    }

    .patient-topbar {
        grid-template-columns: 1fr;
    }

    .patient-topbar-left,
    .patient-topbar-right,
    .patient-balance-wrap {
        justify-content: center;
    }

}

@media (max-width: 1100px) {
    .visit-grid,
    .visit-followup-row {
        grid-template-columns: 1fr 1fr;
    }

    .summary-col,
    .finance-col,
    .visit-followup-reason,
    .visit-followup-notes,
    .visit-delete-action {
        grid-column: span 2;
    }
}

@media (max-width: 1200px) {
    .quick-search {
        min-width: 100%;
    }

    .patients-table-wrapper,
    .followups-table-wrapper {
        max-height: 420px;
    }

    .left-grid.two-cols,
    .three-col-head,
    .three-col-body,
    .history-grid {
        grid-template-columns: 1fr;
    }

    .three-col-cell.small-cell {
        max-width: none;
    }

    .patient-tab-content {
        min-height: auto;
    }

    .work-log-box {
        min-height: 280px;
        max-height: 280px;
    }

    .history-card textarea {
        min-height: 220px;
    }
}

@media (max-width: 900px) {
    .followup-inline,
    .finance-grid-head,
    .finance-grid-body {
        grid-template-columns: 1fr;
    }

    .visit-grid,
    .visit-followup-row {
        grid-template-columns: 1fr;
    }

    .visit-followup-reason,
    .visit-followup-notes,
    .visit-delete-action {
        grid-column: auto;
    }
}

.patient-relationships-card {
    padding: 16px;
    border: 1px solid #d9e7ef;
    border-radius: 12px;
    background: #f8fbfd;
}

.operations-page {
    min-height: calc(100vh - 58px);
    padding: 28px;
    background: #edf6fb;
}

.expenses-page {
    min-height: calc(100vh - 58px);
    padding: 28px;
    background: #edf6fb;
}

.expenses-shell {
    width: min(1500px, 100%);
    margin: 0 auto;
}

.expenses-layout {
    display: grid;
    grid-template-columns: minmax(340px, 390px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.expense-types-card,
.expenses-main-card {
    padding: 20px;
    border: 1px solid #d8e5ed;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 14px 36px rgba(31, 73, 96, 0.08);
}

.expense-types-card h2 {
    margin: 0 0 14px;
    color: #244558;
    font-size: 1.05rem;
    font-weight: 800;
}

.expense-type-create {
    display: grid;
    gap: 8px;
    padding-bottom: 14px;
    border-bottom: 1px solid #e3edf2;
}

.expense-types-list {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.expense-type-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-items: center;
    padding: 10px;
    border: 1px solid #dce8ef;
    border-radius: 10px;
    background: #f9fcfd;
}

.expense-type-update {
    display: contents;
}

.expense-type-update input {
    grid-column: 1 / -1;
    width: 100%;
}

.expense-type-update .btn,
.expense-type-delete .btn {
    width: 100%;
}

.expense-type-delete {
    margin: 0;
}

.expenses-summary {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 14px;
}

.expenses-summary > div {
    display: flex;
    min-width: 260px;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 14px;
    border: 1px solid #cfe2ec;
    border-radius: 11px;
    background: #f0f8fc;
    color: #31576d;
}

.expenses-summary strong {
    color: #174d6b;
    font-size: 1.05rem;
}

.expense-create-form {
    display: grid;
    grid-template-columns: minmax(180px, .9fr) 150px 130px minmax(230px, 1.4fr) auto;
    gap: 10px;
    align-items: end;
    margin-bottom: 22px;
    padding: 15px;
    border: 1px solid #d9e8f0;
    border-radius: 12px;
    background: #f7fbfd;
}

.expenses-list-header,
.expense-update-form {
    display: grid;
    grid-template-columns: 145px minmax(180px, .8fr) 120px minmax(220px, 1.2fr) 105px;
    gap: 8px;
    align-items: center;
}

.expenses-list-header {
    padding: 9px 10px;
    border-radius: 9px 9px 0 0;
    background: #e7f3f9;
    color: #31576d;
    font-size: .76rem;
    font-weight: 800;
}

.expenses-editable-list {
    border: 1px solid #dce8ef;
    border-top: 0;
    border-radius: 0 0 10px 10px;
}

.expense-edit-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid #e6eef2;
}

.expense-edit-row:last-child {
    border-bottom: 0;
}

@media (max-width: 1100px) {
    .expenses-layout,
    .expense-create-form,
    .expenses-list-header,
    .expense-update-form,
    .expense-edit-row {
        grid-template-columns: 1fr;
    }

    .expenses-list-header {
        display: none;
    }
}

.operations-card {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 24px;
    border: 1px solid #d8e5ed;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 16px 42px rgba(31, 73, 96, 0.1);
}

.operation-create-form {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 160px auto auto;
    gap: 12px;
    align-items: end;
    margin: 20px 0 26px;
    padding: 16px;
    border: 1px solid #d9e8f0;
    border-radius: 12px;
    background: #f5fafc;
}

.operation-extraction-toggle {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    gap: 7px;
    margin: 0;
    color: #355263;
    font-weight: 700;
    white-space: nowrap;
}

.operation-extraction-toggle.compact {
    justify-content: center;
}

.operations-list-header,
.operation-update-form {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 150px 130px 110px;
    gap: 10px;
    align-items: center;
}

.operations-list-header {
    padding: 9px 12px;
    border-radius: 9px 9px 0 0;
    background: #e7f3f9;
    color: #31576d;
    font-size: 0.78rem;
    font-weight: 800;
}

.operations-editable-list {
    border: 1px solid #dce8ef;
    border-top: 0;
    border-radius: 0 0 10px 10px;
}

.operation-edit-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 9px 12px;
    border-bottom: 1px solid #e7eef2;
}

.operation-edit-row:last-child {
    border-bottom: 0;
}

.operation-delete-form {
    margin: 0;
}

@media (max-width: 900px) {
    .operations-page {
        padding: 12px;
    }

    .operation-create-form,
    .operations-list-header,
    .operation-update-form,
    .operation-edit-row {
        grid-template-columns: 1fr;
    }

    .operations-list-header {
        display: none;
    }
}

.patient-relationships-help {
    margin-top: 3px;
    color: #668091;
    font-size: 0.8rem;
}

.relationship-create-grid {
    display: grid;
    grid-template-columns: minmax(240px, 1.5fr) minmax(180px, 0.8fr) auto;
    gap: 10px;
    align-items: end;
    margin-top: 14px;
}

.relationship-search-wrap {
    position: relative;
}

.relationship-search-results {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    left: 0;
    z-index: 50;
    overflow: hidden;
    border: 1px solid #cddde7;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(24, 61, 82, 0.18);
}

.relationship-search-result {
    display: block;
    width: 100%;
    padding: 9px 11px;
    border: 0;
    border-bottom: 1px solid #edf2f5;
    background: #fff;
    color: #244558;
    text-align: left;
}

.relationship-search-result:hover {
    background: #edf7fc;
}

.relationship-search-empty {
    padding: 10px;
    color: #718896;
}

.relationship-error {
    margin-top: 8px;
    color: #a02626;
    font-size: 0.82rem;
    font-weight: 700;
}

.patient-relationships-list {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.patient-relationship-item {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto auto auto;
    gap: 10px;
    align-items: center;
    padding: 9px 10px;
    border: 1px solid #e0eaf0;
    border-radius: 10px;
    background: #fff;
}

.patient-relationship-name {
    color: #176c9d;
    font-weight: 800;
    text-decoration: none;
}

.patient-relationship-name.is-archived {
    color: #82939d;
    pointer-events: none;
}

.patient-relationship-type,
.patient-relationship-archived {
    padding: 4px 8px;
    border-radius: 999px;
    background: #e8f4fa;
    color: #315b72;
    font-size: 0.76rem;
    font-weight: 700;
}

.patient-relationship-archived {
    background: #f1f1f1;
    color: #6f777c;
}

@media (max-width: 900px) {
    .relationship-create-grid,
    .patient-relationship-item {
        grid-template-columns: 1fr;
    }
}

.visit-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 36, 49, 0.45);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 24px;
    z-index: 99999;
    overflow-y: auto;
}

.visit-modal-overlay.is-open {
    display: flex;
}

.visit-modal-window {
    width: 95vw;
    min-height: 640px;
    max-height: calc(100vh - 48px);
    margin: auto;
    background: #eef3f8;
    border: 1px solid #cfdbe5;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(18, 42, 56, 0.25);
    display: flex;
    flex-direction: column;
}

.visit-modal-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    background: #e4ebf2;
    border-bottom: 1px solid #cfdae3;
}

.visit-modal-header-left,
.visit-modal-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.visit-modal-header-right {
    justify-content: flex-end;
}

.visit-chart-switch {
    flex-wrap: wrap;
}

.periodontal-panel {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    overflow: auto;
}

.periodontal-panel[hidden] {
    display: none;
}

.periodontal-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.periodontal-title {
    color: #244558;
    font-size: 1.05rem;
    font-weight: 800;
}

.periodontal-help,
.periodontal-save-status {
    color: #637d8d;
    font-size: 0.78rem;
}

.periodontal-actions,
.periodontal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.periodontal-save-status.is-dirty {
    color: #a56b00;
    font-weight: 800;
}

.periodontal-save-status.is-saved {
    color: #23744a;
    font-weight: 800;
}

.periodontal-legend {
    padding: 8px 10px;
    border: 1px solid #dce7ed;
    border-radius: 9px;
    background: #fff;
    color: #506b7a;
    font-size: 0.74rem;
}

.periodontal-chart-container {
    display: grid;
    gap: 16px;
}

.periodontal-arch {
    padding: 10px;
    border: 1px solid #d5e3eb;
    border-radius: 12px;
    background: #fff;
}

.periodontal-arch h3 {
    margin: 0 0 8px;
    color: #29485b;
    font-size: 0.9rem;
    font-weight: 800;
}

.periodontal-table-scroll {
    overflow-x: auto;
}

.periodontal-table {
    width: 100%;
    min-width: 1380px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.7rem;
}

.periodontal-table th,
.periodontal-table td {
    padding: 5px;
    border-right: 1px solid #e2ebf0;
    border-bottom: 1px solid #e2ebf0;
    text-align: center;
    vertical-align: middle;
}

.periodontal-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #eaf4f9;
    color: #29485b;
}

.periodontal-table thead small {
    display: block;
    margin-top: 2px;
    color: #6a8291;
    font-size: 0.58rem;
}

.periodontal-tooth-row > th {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #f1f8fb;
    color: #1f5f83;
    font-size: 0.82rem;
}

.periodontal-tooth-row.is-missing {
    opacity: 0.48;
    background: #eef0f1;
}

.periodontal-site-numbers,
.periodontal-site-checks {
    display: flex;
    justify-content: center;
    gap: 3px;
}

.periodontal-site-checks {
    margin-top: 4px;
}

.periodontal-number {
    width: 38px;
    min-height: 28px;
    padding: 2px;
    border: 1px solid #cbdbe4;
    border-radius: 5px;
    text-align: center;
}

.periodontal-check {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    margin: 0;
    color: #567080;
    font-size: 0.58rem;
}

.periodontal-check input {
    width: 12px;
    height: 12px;
    margin: 0;
}

.periodontal-matrix {
    width: 100%;
    min-width: 1120px;
    border-collapse: collapse;
    table-layout: fixed;
    background: #fff;
    font-size: 0.68rem;
}

.periodontal-matrix th,
.periodontal-matrix td {
    height: 25px;
    padding: 1px;
    border: 1px solid #cadbe8;
    text-align: center;
}

.periodontal-matrix .perio-row-label {
    position: sticky;
    left: 0;
    z-index: 3;
    width: 150px;
    padding: 3px 7px;
    background: #dce9f7;
    color: #274a60;
    text-align: left;
    white-space: nowrap;
}

.periodontal-matrix thead .perio-row-label {
    z-index: 4;
}

.perio-tooth-heading {
    background: #12cbd2;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 800;
}

.perio-tooth-heading.is-missing {
    background: #6f7a80;
    opacity: 0.55;
}

.perio-side-start td,
.perio-side-start th {
    border-top-width: 3px;
    border-top-color: #7fa2bd;
}

.perio-status-row td {
    background: #f0f2f3;
}

.perio-matrix-number,
.perio-status-number {
    width: 100%;
    height: 22px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #213c4d;
    text-align: center;
    outline: none;
    -moz-appearance: textfield;
}

.perio-matrix-number::-webkit-inner-spin-button,
.perio-status-number::-webkit-inner-spin-button {
    appearance: none;
}

.perio-matrix-number:focus,
.perio-status-number:focus {
    background: #e5f7ff;
    box-shadow: inset 0 0 0 2px #2f8fd0;
}

.perio-matrix-number.is-alert {
    color: #e23030;
    font-weight: 900;
}

.perio-matrix-check {
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: #df3434;
}

.perio-graphic-block {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    align-items: center;
    margin-top: 10px;
}

.perio-graphic-title {
    color: #173f55;
    font-size: 0.85rem;
    font-weight: 900;
    text-align: center;
}

.perio-graphic-scroll {
    overflow-x: auto;
}

.perio-graphic {
    width: 100%;
    min-width: 1160px;
    height: 190px;
    display: block;
}

.perio-grid-line {
    stroke: #d9dfe3;
    stroke-width: 1;
}

.perio-zero-line {
    stroke: #285cff;
    stroke-width: 2;
}

.perio-axis-label {
    fill: #667984;
    font-size: 8px;
}

.perio-tooth-shape {
    fill: #f4f1dc;
    fill-opacity: 0.82;
    stroke: #9d9b82;
    stroke-width: 1.2;
}

.perio-tooth-number {
    fill: #2a5268;
    font-size: 10px;
    font-weight: 800;
    text-anchor: middle;
}

.perio-tooth-graphic.is-missing {
    opacity: 0.12;
}

.perio-recession-line,
.perio-depth-line {
    fill: none;
    stroke-linejoin: round;
    stroke-linecap: round;
    pointer-events: none;
}

.perio-probe-bar {
    stroke: #187333;
    stroke-width: 2;
}

.perio-probe-bar.has-bleeding {
    stroke: #e32323;
    stroke-width: 3;
}

.perio-recession-line {
    stroke: #18843b;
    stroke-width: 2;
}

.perio-depth-line {
    stroke: #202629;
    stroke-width: 2;
}

@media (max-width: 900px) {
    .perio-graphic-block {
        grid-template-columns: 1fr;
    }

    .perio-graphic-title {
        text-align: left;
    }
}

.visit-modal-title {
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    color: #29485b;
}

.modal-patient-select {
    min-width: 170px;
}

.visit-modal-body {
    display: grid;
    grid-template-columns: 120px 1fr;
    min-height: 0;
    flex: 1;
}

.visit-modal-body.is-periodontal-view {
    grid-template-columns: 1fr;
}

.visit-modal-body.is-periodontal-view .visit-modal-left {
    display: none;
}

.visit-modal-left {
    border-right: 1px solid #d4e0e9;
    padding: 12px;
    background: #f5f8fb;
}

.visit-modal-side-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #355263;
    margin-bottom: 10px;
    line-height: 1.2;
}

.visit-date-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.visit-date-item {
    border: 1px solid #c9d7e1;
    background: #fff;
    color: #29485b;
    border-radius: 8px;
    padding: 10px 8px;
    font-size: 0.86rem;
    font-weight: 700;
    text-align: center;
}

.visit-date-item.active {
    background: #e9f4fc;
    border-color: #9dc8e3;
}

.visit-modal-main {
    padding: 12px;
    overflow: auto;
}

.visit-modal-top {
    display: grid;
    grid-template-columns: 1fr 160px;
    gap: 14px;
    align-items: start;
    margin-bottom: 14px;
}

.visit-summary-panel {
    min-width: 0;
}

.visit-modal-label,
.visit-modal-form-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #355263;
    margin-bottom: 6px;
}

.modal-summary-text {
    min-height: 92px;
    font-size: 0.8rem;
}

.visit-modal-top-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.visit-modal-form {
    background: #f9fcfe;
    border: 1px solid #deebf2;
    border-radius: 12px;
    padding: 12px;
}

.visit-modal-form-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

.visit-modal-entries {
    margin-top: 14px;
}

.visit-entries-list {
    border: 1px solid #dce8ef;
    border-radius: 10px;
    background: #fff;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 80px;
}

.visit-entry-item {
    padding: 8px 10px;
    border-radius: 8px;
    background: #f7fafc;
    border: 1px solid #edf2f6;
    font-size: 0.8rem;
    color: #29485b;
}

@media (max-width: 1100px) {
    .visit-modal-form-grid {
        grid-template-columns: 1fr 1fr;
    }

    .visit-modal-top {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .visit-modal-body {
        grid-template-columns: 1fr;
    }

    .visit-modal-left {
        border-right: 0;
        border-bottom: 1px solid #d4e0e9;
    }

    .visit-modal-form-grid {
        grid-template-columns: 1fr;
    }

    .visit-modal-header {
        grid-template-columns: 1fr;
    }

    .visit-modal-title {
        text-align: left;
    }
}

/* =========================================
   COMPACT LEFT COLUMN - ACCESS STYLE
========================================= */

.patient-left-panel,
.patient-main-card,
.patient-right-panel {
    height: calc(100vh - 120px);
}

.patient-left-panel,
.patient-right-panel {
    overflow: auto;
}

.patient-main-card {
    display: flex;
    flex-direction: column;
}

.patient-tab-content {
    flex: 1;
    overflow: auto;
    min-height: 0;
}

/* πιο compact πρώτη στήλη */
.patient-left-panel {
    padding: 10px;
    border-radius: 12px;
}

.attention-box {
    margin-bottom: 8px;
    padding: 8px;
    font-size: 0.76rem;
    border-radius: 8px;
}

.compact-top-row {
    display: grid;
    grid-template-columns: 1fr 72px;
    gap: 6px;
    margin-bottom: 8px;
    align-items: stretch;
}

.compact-gdpr-box {
    margin: 0;
    padding: 8px;
    border-radius: 8px;
}

.compact-inline-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.compact-head-title {
    font-size: 0.74rem;
    font-weight: 800;
    color: #355263;
}

.compact-inline-field label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    color: #355263;
    margin-bottom: 3px;
}

.compact-plith-box {
    border: 1px solid #dce8ef;
    background: #f8fbfd;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
}

.compact-field {
    margin-bottom: 6px;
}

.compact-field label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    color: #355263;
    margin-bottom: 3px;
    line-height: 1.15;
}

.compact-inline-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.compact-inline-3 {
    display: grid;
    grid-template-columns: 1.2fr 0.7fr 0.7fr;
    gap: 6px;
}

.compact-small-field {
    min-width: 0;
}

.compact-attach-row {
    margin-top: 2px;
}

.compact-phone-row {
    display: grid;
    grid-template-columns: 1fr 82px 28px;
    gap: 6px;
    align-items: end;
}

.phone-number-field,
.phone-type-field,
.phone-check-field {
    min-width: 0;
}

.compact-check-box {
    min-height: 36px;
    border: 1px solid #d7e4ec;
    border-radius: 10px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.compact-check-box-no-label {
    margin-top: 0;
}

.compact-textarea {
    min-height: 48px;
    resize: vertical;
}

.compact-comment-box {
    min-height: 42px;
}

.patient-left-panel .modern-input {
    min-height: 32px;
    padding: 5px 8px;
    font-size: 0.78rem;
    border-radius: 8px;
}

.patient-left-panel textarea.modern-input {
    padding-top: 6px;
    padding-bottom: 6px;
}

.patient-left-panel .checkbox-line {
    font-size: 0.74rem;
    gap: 5px;
}

.patient-left-panel input[type="checkbox"] {
    transform: scale(0.9);
}

/* το δεξί panel και το κεντρικό να ακολουθούν πιο σωστά */
.patient-right-panel {
    padding: 10px;
}

.work-log-box {
    min-height: 380px;
    max-height: 380px;
}

@media (max-width: 1600px) {
    .patient-left-panel,
    .patient-main-card,
    .patient-right-panel {
        height: auto;
    }

    .patient-tab-content,
    .patient-left-panel,
    .patient-right-panel {
        overflow: visible;
    }
}

@media (max-width: 1200px) {
    .compact-inline-2,
    .compact-inline-3,
    .compact-phone-row,
    .compact-top-row {
        grid-template-columns: 1fr;
    }

    .compact-plith-box {
        justify-content: flex-start;
    }
}

/* =========================================
   STATS MODAL
========================================= */

.stats-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 36, 49, 0.45);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 24px;
    z-index: 99999;
    overflow-y: auto;
}

.stats-modal-overlay.is-open {
    display: flex;
}

.stats-modal-window {
    width: min(1260px, 96vw);
    min-height: 680px;
    max-height: calc(100vh - 48px);
    margin: auto;
    background: #eef2f6;
    border: 1px solid #cfdbe5;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(18, 42, 56, 0.25);
    display: flex;
    flex-direction: column;
}

.stats-modal-header {
    background: #dfe6ec;
    border-bottom: 1px solid #ccd8e1;
    padding: 8px 10px 0 10px;
}

.stats-modal-tabs {
    display: flex;
    gap: 4px;
}

.stats-modal-tab {
    background: #f4f7fa;
    border: 1px solid #cfdbe5;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    padding: 7px 12px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #29485b;
}

.stats-modal-tab.active {
    background: #ffffff;
}

.stats-modal-body {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 0;
    flex: 1;
}

.stats-sidebar {
    padding: 12px;
    border-right: 1px solid #d4e0e9;
    background: #f5f8fb;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stats-back-wrap {
    display: flex;
    justify-content: flex-start;
}

.stats-filter-box {
    border: 1px solid #dce8ef;
    border-radius: 10px;
    background: #fff;
    padding: 10px;
}

.stats-filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.stats-filter-field label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: #355263;
    margin-bottom: 4px;
}

.stats-filter-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stats-show-btn {
    min-width: auto;
    font-size: 0.82rem;
    padding: 8px 12px;
}

.stats-finance-box {
    background: #2e5f9d;
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stats-finance-row {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 8px;
    align-items: center;
}

.stats-finance-row label {
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
    margin: 0;
}

.stats-main {
    padding: 14px;
    overflow: auto;
}

.stats-date-range {
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    color: #29485b;
    margin-bottom: 10px;
}

.stats-summary-cards {
    display: grid;
    grid-template-columns: 240px 260px;
    gap: 10px;
    margin-bottom: 14px;
}

.stats-summary-card {
    background: #fff;
    border: 1px solid #dce8ef;
    border-radius: 10px;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: 1fr 70px;
    gap: 8px;
    align-items: center;
}

.stats-summary-label {
    font-size: 0.84rem;
    font-weight: 700;
    color: #29485b;
}

.stats-summary-value {
    border: 1px solid #cfdbe5;
    background: #f8fbfd;
    border-radius: 8px;
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: #29485b;
}

.stats-grid {
    display: grid;
    grid-template-columns: 240px 1fr 260px;
    gap: 10px;
    align-items: start;
}

.stats-table-column {
    display: grid;
    gap: 10px;
}

.stats-table-card {
    background: #fff;
    border: 1px solid #dce8ef;
    border-radius: 10px;
    overflow: hidden;
}

.stats-table-tall {
    max-height: 640px;
    overflow: auto;
}

.stats-table-card .modern-table {
    font-size: 0.78rem;
}

.stats-table-card .modern-table th,
.stats-table-card .modern-table td {
    padding: 6px 8px;
}

@media (max-width: 1100px) {
    .stats-modal-body {
        grid-template-columns: 1fr;
    }

    .stats-sidebar {
        border-right: 0;
        border-bottom: 1px solid #d4e0e9;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stats-summary-cards {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .stats-filter-row {
        grid-template-columns: 1fr;
    }
}

.statistics-page { min-height: calc(100vh - 70px); background: #eef7fb; padding: 32px 24px 56px; }
.statistics-shell { width: min(1500px, 100%); margin: 0 auto; }
.statistics-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.statistics-header h1 { margin: 0 0 5px; color: #173f58; font-size: 2rem; font-weight: 800; }
.statistics-header p { margin: 0; color: #607f92; }
.statistics-filter-card { display: grid; grid-template-columns: minmax(180px, 240px) minmax(180px, 240px) auto auto; align-items: end; gap: 14px; padding: 20px; border: 1px solid #d7e6ee; border-radius: 16px; background: #fff; box-shadow: 0 10px 28px rgba(35, 75, 98, .07); }
.statistics-filter-field label { display: block; margin-bottom: 6px; color: #29485b; font-weight: 700; }
.statistics-period { margin: 22px 0 14px; color: #4f7185; font-weight: 700; }
.statistics-summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 22px; }
.statistics-summary-card { display: flex; justify-content: space-between; align-items: center; min-height: 112px; padding: 24px; border: 1px solid #d7e6ee; border-radius: 16px; background: #fff; box-shadow: 0 10px 28px rgba(35, 75, 98, .06); }
.statistics-summary-card span { color: #607f92; font-weight: 700; }
.statistics-summary-card strong { color: #123f5b; font-size: 2rem; }
.statistics-section { padding: 24px; margin-bottom: 22px; border: 1px solid #d7e6ee; border-radius: 16px; background: #fff; }
.statistics-section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.statistics-section-heading h2, .statistics-table-card h2 { margin: 0; color: #173f58; font-size: 1.2rem; font-weight: 800; }
.statistics-section-heading span { color: #718b9b; font-size: .9rem; }
.statistics-finance-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.statistics-finance-grid article { display: flex; flex-direction: column; gap: 7px; padding: 18px; border-radius: 12px; background: #f3f8fb; border: 1px solid #deebf1; }
.statistics-finance-grid span { color: #607f92; font-size: .86rem; font-weight: 700; }
.statistics-finance-grid strong { color: #173f58; font-size: 1.4rem; }
.statistics-finance-grid .statistics-expense-total { background: #fff5dc; border-color: #f0d997; }
.statistics-finance-grid .statistics-expense-total strong { color: #8a6414; }
.statistics-tables-grid { display: grid; grid-template-columns: 1.15fr 1.35fr 1fr; gap: 18px; align-items: start; }
.statistics-table-stack { display: grid; gap: 18px; }
.statistics-table-card { overflow: hidden; border: 1px solid #d7e6ee; border-radius: 16px; background: #fff; box-shadow: 0 10px 28px rgba(35, 75, 98, .05); }
.statistics-table-card h2 { padding: 20px 20px 14px; }
.statistics-table-card .modern-table th, .statistics-table-card .modern-table td { padding: 12px 20px; }

@media (max-width: 1050px) {
    .statistics-filter-card { grid-template-columns: 1fr 1fr; }
    .statistics-tables-grid { grid-template-columns: 1fr 1fr; }
    .statistics-table-stack { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
    .statistics-page { padding: 22px 12px 40px; }
    .statistics-header, .statistics-section-heading { align-items: flex-start; }
    .statistics-filter-card, .statistics-summary-grid, .statistics-finance-grid, .statistics-tables-grid, .statistics-table-stack { grid-template-columns: 1fr; }
    .statistics-table-stack { grid-column: auto; }
}

/* =========================================
   DENTAL SVG CHART
========================================= */
.patient-dental-record { margin-top: 18px; padding: 22px; border: 1px solid #d6e5ed; border-radius: 16px; background: #fff; }
.dental-record-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.dental-record-heading h2 { margin: 0; color: #173f58; font-size: 1.25rem; font-weight: 800; }
.dental-record-heading p { margin: 5px 0 0; color: #688394; }
.dental-record-dentition-switch, .dental-record-tabs { display: flex; gap: 8px; }
.dental-record-tabs { margin-top: 20px; padding-bottom: 12px; border-bottom: 1px solid #dae7ee; }
.dental-record-tabs button { padding: 9px 15px; border: 1px solid #d5e2ea; border-radius: 9px; color: #355468; background: #f7fafc; font-weight: 700; }
.dental-record-tabs button.active { color: #fff; border-color: #319bd1; background: #319bd1; }
.dental-record-panel { padding-top: 18px; }
.dental-record-chart { display: grid; gap: 14px; overflow-x: auto; padding: 20px; border: 1px solid #dbe8ef; border-radius: 14px; background: #f7fbfd; }
.dental-record-svg { min-width: 880px; }
.dental-record-chart .tooth-surface.record-state:not(.selected) { fill: color-mix(in srgb, var(--record-state-color) 58%, white); stroke: var(--record-state-color); }
.dental-record-chart .tooth-surface.is-readonly { cursor: default; }
.dental-record-chart .tooth-surface.is-readonly:hover { filter: none; }
.dental-record-arch { display: flex; justify-content: center; gap: 7px; min-width: 830px; }
.dental-record-tooth { width: 46px; padding: 2px; border: 0; color: #456476; background: transparent; }
.dental-record-tooth-shape { display: block; width: 34px; height: 48px; margin: auto; border: 2px solid #9db3bf; background: #fff; transition: .15s ease; }
.dental-record-tooth.is-upper .dental-record-tooth-shape { border-radius: 45% 45% 32% 32% / 26% 26% 58% 58%; }
.dental-record-tooth.is-lower .dental-record-tooth-shape { border-radius: 32% 32% 45% 45% / 58% 58% 26% 26%; }
.dental-record-tooth.has-record .dental-record-tooth-shape { border-color: var(--tooth-state-color); background: color-mix(in srgb, var(--tooth-state-color) 55%, white); }
.dental-record-tooth.is-selected .dental-record-tooth-shape { outline: 3px solid #1698d4; outline-offset: 2px; transform: translateY(-2px); }
.dental-record-tooth.is-extracted { opacity: .35; }
.dental-record-tooth small { display: block; margin-top: 4px; font-weight: 800; }
.dental-record-editor { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 12px; align-items: end; margin-top: 16px; padding: 16px; border-radius: 12px; background: #f1f7fa; }
.dental-record-editor label { display: block; margin-bottom: 5px; color: #355468; font-size: .82rem; font-weight: 700; }
.dental-record-wide { grid-column: span 2; }
.dental-record-list { display: grid; gap: 8px; margin-top: 16px; }
.dental-record-list-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 14px; border: 1px solid #dce8ef; border-radius: 10px; }
.dental-record-list-row strong, .dental-record-list-row span { display: block; }
.dental-record-list-row span { margin-top: 2px; color: #688394; font-size: .82rem; }
.dental-record-list-row p { margin: 5px 0 0; color: #355468; white-space: pre-wrap; }
.dental-record-list-row.is-completed-plan-item { border-color: #a9d6b5; background: #f1faf3; }
.treatment-plan-completed-badge { display: inline-flex !important; width: fit-content; margin: 0 0 7px; padding: 5px 9px; border-radius: 999px; color: #216c38 !important; background: #dff3e4; font-size: .78rem !important; font-weight: 800; }
.dental-record-readonly-note { margin-bottom: 12px; padding: 10px 14px; border-radius: 9px; color: #456476; background: #eaf5fa; }
@media (max-width: 900px) { .dental-record-editor { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .dental-record-heading, .dental-record-list-row { flex-direction: column; align-items: stretch; } .dental-record-tabs { overflow-x: auto; } .dental-record-tabs button { white-space: nowrap; } .dental-record-editor { grid-template-columns: 1fr; } .dental-record-wide { grid-column: auto; } }



.dental-chart-panel {
    background: #fff;
    border: 1px solid #dce8ef;
    border-radius: 10px;
    padding: 10px;
}

.dental-chart-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.selected-teeth-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 220px;
}

.selected-teeth-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #355263;
    white-space: nowrap;
}

.selected-teeth-input {
    min-height: 34px;
    font-size: 0.8rem;
}

.dental-chart-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.dental-chart-svg-wrap {
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
}

.dental-chart-svg {
    width: 100%;
    min-width: 860px;
    height: auto;
    display: block;
}

.dental-midline-divider {
    stroke: #cfdbe5;
    stroke-width: 2;
    stroke-dasharray: 5 5;
}

.tooth-group {
    cursor: pointer;
}

.tooth-shape {
    fill: #f8fbfd;
    stroke: #9db6c7;
    stroke-width: 1.5;
    transition: 0.15s ease;
}

.tooth-label {
    font-size: 11px;
    font-weight: 700;
    fill: #29485b;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
}

.tooth-group:hover .tooth-shape {
    fill: #eaf5fc;
    stroke: #5fa7d1;
}

.tooth-group.selected .tooth-shape {
    fill: #2f8fd0;
    stroke: #1f6fa5;
}

.tooth-group.selected .tooth-label {
    fill: #ffffff;
}

@media (max-width: 900px) {
    .dental-chart-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .selected-teeth-wrap {
        width: 100%;
    }
}

/* =========================================
   FIXED VISIT MODAL LAYOUT
========================================= */

.visit-modal-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.visit-modal-teeth-section {
    width: 100%;
}

.visit-modal-entry-grid {
    display: grid;
    grid-template-columns: 1fr 170px;
    gap: 12px;
    align-items: start;
}

.visit-entry-inline-grid {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 12px;
    align-items: start;
}

.visit-entry-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dental-chart-panel {
    background: #fff;
    border: 1px solid #dce8ef;
    border-radius: 10px;
    padding: 10px;
}

.dental-chart-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.surface-mode-hint {
    font-size: 0.78rem;
    font-weight: 700;
    color: #355263;
    margin-bottom: 8px;
}

.dental-chart-svg-wrap {
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
}

.dental-chart-svg {
    width: 100%;
    min-width: 880px;
    height: auto;
    display: block;
}

.tooth-surface {
    fill: #f8fbfd;
    stroke: #9db6c7;
    stroke-width: 1.2;
    transition: 0.15s ease;
    cursor: pointer;
}

.tooth-outline {
    fill: none;
    stroke: #7ea1b8;
    stroke-width: 1.5;
    stroke-linejoin: round;
    pointer-events: none;
}

.tooth-number {
    font-size: 10px;
    font-weight: 700;
    fill: #29485b;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
}

.tooth-surface:hover {
    fill: #eaf5fc;
    stroke: #5fa7d1;
}

.tooth-surface.selected {
    fill: #2f8fd0;
    stroke: #1f6fa5;
}

.dental-history-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: -2px 0 8px;
    color: #536d7c;
    font-size: 0.74rem;
    font-weight: 700;
}

.dental-history-legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.dental-legend-swatch {
    width: 15px;
    height: 15px;
    border: 1px solid #9db6c7;
    border-radius: 4px;
    background: #f8fbfd;
}

.dental-legend-swatch.worked {
    border-color: #d4a62a;
    background: #ffe49a;
}

.dental-legend-swatch.extracted {
    border-style: dashed;
    background: rgba(101, 118, 129, 0.22);
}

.dental-legend-swatch.selected {
    border-color: #1f6fa5;
    background: #2f8fd0;
}

.tooth-surface.historical-worked:not(.selected) {
    fill: #ffe49a;
    stroke: #d4a62a;
}

.tooth-group.historical-extracted {
    opacity: 0.3;
}

.tooth-group.historical-extracted .tooth-outline {
    stroke: #657681;
    stroke-dasharray: 4 3;
}

.tooth-group.historical-extracted .tooth-surface.selected {
    opacity: 1;
    fill: #2f8fd0;
}

.surface-label {
    font-size: 8px;
    font-weight: 700;
    fill: #5b7486;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
}

.tooth-surface.selected + .surface-label,
.tooth-surface.selected ~ .surface-label.active-for-selected {
    fill: #ffffff;
}

@media (max-width: 1100px) {
    .visit-modal-entry-grid {
        grid-template-columns: 1fr;
    }

    .visit-entry-inline-grid {
        grid-template-columns: 1fr;
    }
}

.active-mode-btn {
    background: #2f8fd0 !important;
    color: #fff !important;
    border-color: #2f8fd0 !important;
}

.visit-entry-item {
    cursor: pointer;
}

.visit-entry-item.active {
    background: #e9f4fc;
    border-color: #9dc8e3;
    color: #16394d;
    font-weight: 700;
}

.is-disabled-btn {
    opacity: 0.45;
    pointer-events: none;
}

.pagination-outside {
    border-top: 1px solid #d9e7ef;
    background: #fff;
    padding: 8px 10px;
}

.dashboard-pagination {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    font-size: 0.78rem;
}

.page-btn {
    min-height: 28px;
    min-width: 28px;
    padding: 4px 8px;
    border: 1px solid #d7e5ed;
    border-radius: 6px;
    background: #fff;
    color: #2c4858;
    text-decoration: none;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.page-btn:hover {
    background: #eef7fc;
    color: #16394d;
}

.page-btn.active {
    background: #2489c5;
    border-color: #2489c5;
    color: #fff;
}

.page-btn.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.page-dots {
    padding: 0 3px;
    color: #7a8f9b;
}

.page-info {
    margin-left: 6px;
    color: #456273;
    font-weight: 600;
}

.page-jump-form {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
}

.page-jump-input {
    width: 58px;
    min-height: 28px;
    border: 1px solid #d7e4ec;
    border-radius: 6px;
    padding: 3px 6px;
    font-size: 0.78rem;
}

.active-filter-btn {
    background: #2489c5 !important;
    border-color: #2489c5 !important;
    color: #fff !important;
}

.wanted-treatment-row {
    margin-bottom: 10px;
}

.empty-tab-message {
    padding: 12px;
    color: #6b7f8c;
    font-size: 0.85rem;
    background: #fff;
    border: 1px solid #e4eef4;
    border-radius: 10px;
}

.wanted-treatment-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.dentition-switch {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e3edf3;
}

.dentition-change-dialog {
    width: min(620px, calc(100vw - 32px));
    padding: 24px;
    border: 1px solid #efcf8d;
    border-radius: 16px;
    background: #fffdf5;
    color: #253746;
    box-shadow: 0 24px 70px rgba(22, 57, 77, 0.3);
}

.dentition-change-dialog::backdrop {
    background: rgba(22, 40, 54, 0.62);
}

.dentition-change-dialog-title {
    margin-bottom: 10px;
    color: #805a0b;
    font-size: 1.15rem;
    font-weight: 800;
}

.dentition-change-dialog p {
    margin-bottom: 20px;
    line-height: 1.55;
}

.dentition-change-dialog-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.google-review-box {
    padding: 10px;
    border: 1px solid #e3c968;
    border-radius: 10px;
    background: #fff6c9;
}

.google-review-toggle {
    justify-content: space-between;
    margin-bottom: 0;
    font-weight: 700;
}

#googleReviewDetails {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

#googleReviewDetails[hidden] {
    display: none;
}

.new-visit-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1300;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(20, 48, 65, 0.55);
    overflow-y: auto;
}

.new-visit-modal-overlay.is-open {
    display: flex;
}

.new-visit-modal-window {
    width: min(100%, 980px);
    max-height: calc(100vh - 48px);
    padding: 24px;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(15, 47, 65, 0.28);
    overflow-y: auto;
}

.new-visit-modal-header,
.new-visit-modal-actions {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.new-visit-form-error {
    margin: 0 auto 0 0;
    padding: 8px 12px;
}

.new-visit-modal-header {
    flex-direction: column;
    align-items: flex-start;
    padding-bottom: 16px;
    border-bottom: 1px solid #dce8ef;
}

.new-visit-modal-header h2,
.new-visit-financial-section h3 {
    margin: 0;
    color: #1d4258;
    font-weight: 800;
}

.new-visit-modal-header p {
    margin: 5px 0 0;
    color: #668091;
}

.new-visit-form {
    display: grid;
    gap: 20px;
    margin-top: 20px;
}

.new-visit-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.new-visit-form-wide {
    grid-column: 1 / -1;
}

.new-visit-financial-section {
    padding: 16px;
    border: 1px solid #dce8ef;
    border-radius: 12px;
    background: #f7fbfd;
}

.new-visit-financial-section h3 {
    margin-bottom: 14px;
    font-size: 1rem;
}

.new-visit-financial-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.new-visit-modal-actions {
    justify-content: flex-end;
    padding-top: 16px;
    border-top: 1px solid #dce8ef;
}

@media (max-width: 760px) {
    .new-visit-form-grid,
    .new-visit-financial-grid {
        grid-template-columns: 1fr;
    }

    .new-visit-form-wide {
        grid-column: auto;
    }
}
