:root {
    --bg: #f4f7fb;
    --bg-card: rgba(255, 255, 255, 0.98);
    --border-glass: rgba(148, 163, 184, 0.45);
    --accent: #2563eb;
    --accent-soft: rgba(37, 99, 235, 0.12);
    --accent-soft-strong: rgba(37, 99, 235, 0.18);
    --accent-secondary: #14b8a6;
    --text-main: #0f172a;
    --text-muted: #6b7280;
    --danger: #dc2626;
    --radius-lg: 14px;
    --radius-pill: 999px;
    --shadow-soft: 0 14px 30px rgba(15, 23, 42, 0.12);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, #e0f2fe, transparent 60%),
        radial-gradient(circle at bottom right, #ccfbf1, #f9fafb 70%);
    color: var(--text-main);
    min-height: 100%;
}

body {
    display: flex;
    justify-content: center;
}

.app-shell {
    width: 100%;
    max-width: 1080px;
    padding: 10px 10px 16px;
}

/* Header / tabs */

.top-bar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 6px 10px;
    margin-bottom: 10px;
    background: linear-gradient(120deg, rgba(37, 99, 235, 0.10), rgba(20, 184, 166, 0.10));
}

.glass {
    background: linear-gradient(145deg, var(--bg-card), rgba(248, 250, 252, 0.95));
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(18px) saturate(130%);
}

.module-tabs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.tab-link {
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    text-decoration: none;
    color: var(--text-muted);
    border: 1px solid transparent;
    background: transparent;
    transition: all 0.15s ease-out;
    white-space: nowrap;
}

.tab-link:hover {
    border-color: var(--accent-soft);
    background: linear-gradient(135deg, rgba(239, 246, 255, 0.9), rgba(236, 253, 245, 0.95));
    color: var(--text-main);
}

.tab-link.active {
    background: linear-gradient(135deg, #2563eb, #14b8a6);
    color: #f9fafb;
    border-color: rgba(37, 99, 235, 0.5);
}

/* Cards and layout */

.main-content {
    display: block;
}

.card {
    padding: 10px 12px 12px;
}

.card-title {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 600;
}

.section-title {
    margin: 0 0 6px;
    font-size: 13px;
    font-weight: 500;
}

.grid-1 {
    display: grid;
    gap: 12px;
}

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

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

.center-container {
    display: flex;
    justify-content: center;
    padding-top: 32px;
}

.auth-card {
    max-width: 360px;
    width: 100%;
}

/* Forms */

.form-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
}

.form-grid.compact {
    gap: 5px;
}

.form-grid.two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 10px;
}

.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
    color: var(--text-muted);
}

.form-grid span {
    font-size: 11px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.9);
    background: linear-gradient(180deg, #f9fafb, #ffffff);
    color: var(--text-main);
    padding: 5px 8px;
    font-size: 13px;
    outline: none;
    min-height: 26px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.22);
    background: #ffffff;
}

textarea {
    resize: vertical;
}

.form-actions {
    margin-top: 4px;
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.form-grid .full-width {
    grid-column: 1 / -1;
}

/* Period form (revenue tab) */

.period-form label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
    color: var(--text-muted);
}

.period-form input[type="date"] {
    min-width: 150px;
}

.period-form {
    align-items: flex-end;
}

.period-form {
    align-items: flex-start;  /* override inline-form center alignment */
}

/* Drop the buttons slightly so they align visually with the middle of the date boxes */
.period-form .btn {
    margin-top: 16px;
}
.period-form a.btn {
    margin-top: 16px;
}


/* Buttons */

.btn {
    border-radius: 999px;
    border: 1px solid transparent;
    padding: 4px 10px;
    font-size: 11px;
    cursor: pointer;
    background: linear-gradient(135deg, #e5e7eb, #f9fafb);
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    white-space: nowrap;
    transition: all 0.15s ease-out;
}

.btn.primary {
    background: linear-gradient(135deg, #2563eb, #14b8a6);
    border-color: rgba(37, 99, 235, 0.85);
    color: #f9fafb;
    font-weight: 600;
}

.btn.ghost {
    background: transparent;
    border-color: rgba(148, 163, 184, 0.8);
}

.btn.danger {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    border-color: rgba(220, 38, 38, 0.85);
    color: #991b1b;
}

.btn.small {
    padding: 3px 8px;
    font-size: 11px;
}

.btn.full-width {
    width: 100%;
}

.btn:hover {
    transform: translateY(-0.5px);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
}

.btn.neutral {
    background: linear-gradient(135deg, #e5e7eb, #f3f4f6);
    border-color: rgba(148, 163, 184, 0.9);
    color: #374151;
    font-weight: 500;
}

.btn.small {
    padding: 3px 8px;
    font-size: 11px;
}

.btn.full-width {
    width: 100%;
}

.btn:hover {
    transform: translateY(-0.5px);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
}


/* Tables */

.table-wrapper {
    border-radius: 10px;
    border: 1px solid rgba(209, 213, 219, 0.9);
    overflow: hidden;
    background: #ffffff;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

th,
td {
    padding: 4px 8px;
    border-bottom: 1px solid rgba(229, 231, 235, 0.9);
    text-align: left;
}

th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: linear-gradient(180deg, #f3f4f6, #e5e7eb);
}

tbody tr:nth-child(even) {
    background: #f9fafb;
}

tbody tr:hover {
    background: linear-gradient(90deg, #e0f2fe, #ecfeff);
}

.col-actions {
    width: 1%;
    white-space: nowrap;
}

/* Subtabs */

.subtab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(209, 213, 219, 0.9);
    padding-bottom: 3px;
}

.subtab-link {
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 12px;
    text-decoration: none;
    color: var(--text-muted);
    border: 1px solid transparent;
    background: transparent;
    transition: all 0.15s ease-out;
}

.subtab-link:hover {
    border-color: var(--accent-soft);
    background: linear-gradient(135deg, #eff6ff, #ecfeff);
    color: var(--text-main);
}

.subtab-link.active {
    background: linear-gradient(135deg, #2563eb, #14b8a6);
    color: #f9fafb;
    border-color: rgba(37, 99, 235, 0.45);
}

.subtab-content {
    margin-top: 6px;
}

/* Misc */

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.inline-form {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.inline-form input[type="text"],
.inline-form input[type="date"],
.inline-form select {
    min-width: 150px;
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.checkbox-inline input {
    width: auto;
    min-height: auto;
}

.flash-container {
    margin-bottom: 8px;
}

.flash {
    padding: 5px 9px;
    border-radius: 10px;
    font-size: 11px;
    margin-bottom: 4px;
}

.flash-error {
    background: #fee2e2;
    border: 1px solid rgba(220, 38, 38, 0.85);
    color: #7f1d1d;
}

.flash-success {
    background: #dcfce7;
    border: 1px solid rgba(22, 163, 74, 0.85);
    color: #14532d;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: 3px 0;
    border-bottom: 1px dashed rgba(209, 213, 219, 0.9);
}

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

.detail-row strong {
    font-weight: 500;
}

.separator {
    border: none;
    border-top: 1px solid rgba(209, 213, 219, 0.9);
    margin: 10px 0;
}

.metric-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.metric {
    min-width: 120px;
    padding: 6px 8px;
    border-radius: 10px;
    background: linear-gradient(135deg, #eff6ff, #ecfeff);
    border: 1px solid rgba(191, 219, 254, 0.9);
}

.metric-label {
    font-size: 11px;
    color: var(--text-muted);
}

.metric-value {
    font-size: 13px;
    font-weight: 600;
}

/* Vaccine journal header */

.journal-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 4px;
    font-size: 12px;
}

/* Bill group tree */

.bill-groups {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bill-group {
    border-radius: 10px;
    border: 1px solid rgba(209, 213, 219, 0.9);
    background: linear-gradient(135deg, #ffffff, #f9fafb);
    overflow: hidden;
}

.bill-group summary {
    list-style: none;
    cursor: pointer;
    padding: 5px 8px;
}

.bill-group summary::-webkit-details-marker {
    display: none;
}

.bill-group-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
}

.bill-group-summary .pet-name {
    font-weight: 600;
}

.bill-group-summary .pet-id {
    margin-left: 6px;
    color: var(--text-muted);
    font-size: 11px;
}

.bill-group-totals {
    display: flex;
    gap: 10px;
    font-size: 11px;
}

.bill-group-table {
    border-radius: 0;
    border-top: 1px solid rgba(229, 231, 235, 0.9);
}

.mt {
    margin-top: 6px;
}

/* --- Appointment scheduler --- */

.controls-card {
    margin-bottom: 8px;
}

.week-day-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

@media (min-width: 720px) {
    .week-day-row {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

.week-nav {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.week-nav span {
    font-weight: 500;
    color: var(--text-main);
}

.week-nav a {
    font-size: 12px;
    text-decoration: none;
    color: var(--accent);
}

.week-nav a:hover {
    text-decoration: underline;
}

.day-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.day-tab {
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 11px;
    text-decoration: none;
    color: var(--text-muted);
    background: transparent;
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    transition: all 0.15s ease-out;
}

.day-tab-date {
    font-size: 10px;
    color: var(--text-muted);
}

.day-tab:hover {
    border-color: var(--accent-soft);
    background: linear-gradient(135deg, #eff6ff, #ecfeff);
    color: var(--text-main);
}

.day-tab.active {
    border-color: rgba(37, 99, 235, 0.65);
    background: linear-gradient(135deg, #2563eb, #14b8a6);
    color: #f9fafb;
}

.day-tab.active .day-tab-date {
    color: #e5f3ff;
}

/* Add-appointment row */

.add-form-row {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
}

.add-form-row label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
    color: var(--text-muted);
    min-width: 150px;
}

.add-form-row .notes-inline {
    min-width: 220px;
}

.form-actions-inline {
    margin-left: auto;
}

/* Schedule table */

.schedule-wrapper {
    margin-top: 6px;
    overflow: auto;
}

.schedule-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    table-layout: fixed;
}

/* vertical separators between doctor columns */
.schedule-table thead th:nth-child(n+3),
.schedule-table tbody td:nth-child(n+3) {
    border-left: 1px solid rgba(209, 213, 219, 1);
}

.schedule-table thead th {
    position: sticky;
    top: 0;
    background: #f3f4f6;
    padding: 3px 2px;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(209, 213, 219, 0.9);
    text-align: center;
}

.time-header {
    width: 60px;
}

.schedule-table tbody td {
    border-bottom: 1px solid rgba(229, 231, 235, 0.9);
}

.time-col {
    width: 60px;
    text-align: right;
    padding-right: 6px;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

.doctor-header {
    font-size: 11px;
}

.doctor-cell {
    padding: 1px 2px;
    vertical-align: top;
}

.slot.free {
    background: transparent;
}

.slot.busy {
    background: rgba(191, 219, 254, 0.35);
}

/* Appointment badges – allow multi-line and wrapped notes */

.appt-badge {
    display: block;
    padding: 4px 6px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.8);
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.95),
        rgba(239, 246, 255, 0.9)
    );
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
    overflow: hidden;
}

.appt-type {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-main);
}

.appt-patient {
    display: block;
    font-size: 11px;
    color: var(--text-main);
}

.appt-note {
    display: block;
    margin-top: 2px;
    font-size: 10px;
    color: var(--text-muted);
    white-space: normal;
    word-break: break-word;
}

.appt-badge {
    position: relative;
}

.appt-delete-form {
    position: absolute;
    top: 2px;
    right: 2px;
    margin: 0;
}

.appt-delete-btn {
    border: none;
    padding: 0;
    width: 14px;
    height: 14px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 14px;
    text-align: center;
    cursor: pointer;
    background: rgba(248, 113, 113, 0.12);
    color: #b91c1c;
}

.appt-delete-btn:hover {
    background: rgba(248, 113, 113, 0.28);
}


/* Small helper text */

.text-muted.small {
    font-size: 11px;
    color: var(--text-muted);
}

/* --- Hospitalization layout --- */

.hosp-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 10px;
}

@media (max-width: 900px) {
    .hosp-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

.hosp-sidebar {
    border-right: 1px solid rgba(209, 213, 219, 0.8);
    padding-right: 8px;
}

@media (max-width: 900px) {
    .hosp-sidebar {
        border-right: none;
        border-bottom: 1px solid rgba(209, 213, 219, 0.8);
        padding-right: 0;
        margin-bottom: 8px;
        padding-bottom: 8px;
    }
}

.hosp-pet-list {
    max-height: 480px;
    overflow-y: auto;
    margin-top: 4px;
}

.hosp-pet-item {
    display: block;
    padding: 4px 6px;
    border-radius: 8px;
    font-size: 12px;
    text-decoration: none;
    color: var(--text-main);
    margin-bottom: 3px;
    border: 1px solid transparent;
}

.hosp-pet-item:hover {
    background: linear-gradient(135deg, #eff6ff, #ecfeff);
    border-color: rgba(191, 219, 254, 1);
}

.hosp-pet-item.active {
    background: linear-gradient(135deg, #2563eb, #14b8a6);
    color: #f9fafb;
    border-color: rgba(37, 99, 235, 0.7);
}

.hosp-pet-name {
    font-weight: 600;
}

.hosp-pet-meta {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    gap: 6px;
}

.hosp-main {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hosp-section {
    border-radius: 10px;
    border: 1px solid rgba(209, 213, 219, 0.9);
    padding: 8px;
    background: linear-gradient(135deg, #ffffff, #f9fafb);
}

/* Status highlighting */

.status-select.status-ok {
    background: #ecfdf3;
    border-color: rgba(34, 197, 94, 0.6);
}

.status-select.status-bad {
    background: #fef2f2;
    border-color: rgba(248, 113, 113, 0.8);
}

/* Treatment plan colors by hour */

.tp-row.tp-hour-morning {
    background: rgba(219, 234, 254, 0.8);
}

.tp-row.tp-hour-noon {
    background: rgba(204, 251, 241, 0.8);
}

.tp-row.tp-hour-evening {
    background: rgba(254, 243, 199, 0.8);
}

.tp-row.tp-hour-night {
    background: rgba(229, 231, 235, 0.8);
}
/* Compact patient section */
.hosp-patient-grid {
    gap: 4px;
}

.hosp-patient-grid label span {
    font-size: 10px;
}

/* Daily status in one row */
.hosp-status-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 6px;
}

.hosp-status-form label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
    color: var(--text-muted);
    min-width: 120px;
}

.hosp-status-note {
    flex: 1 1 220px;
}

.hosp-status-note input {
    width: 100%;
}

/* Make this section visually smaller */
.hosp-section {
    padding: 6px;
}

/* Treatment plan add row: all in one compact line */
.hosp-plan-add-row label {
    min-width: 90px;
}

.hosp-plan-add-row label:nth-child(1) { /* Medicine */
    min-width: 180px;
}

.hosp-plan-add-row label:nth-child(2) { /* Adm type */
    min-width: 120px;
}

.hosp-plan-add-row label:nth-child(5) { /* Hour */
    min-width: 90px;
}

.hosp-plan-add-row label:nth-child(6),   /* Start date */
.hosp-plan-add-row label:nth-child(7) { /* Duration */
    min-width: 90px;
}

.hosp-patient-details {
    margin: 0;
}

.hosp-patient-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 8px;
    background: linear-gradient(135deg, #eff6ff, #ecfeff);
    border: 1px solid rgba(191, 219, 254, 0.9);
    font-size: 12px;
}

.hosp-patient-summary-name {
    font-size: 11px;
    color: var(--text-muted);
}

.hosp-patient-details[open] .hosp-patient-summary {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: transparent;
}

.hosp-patient-details form {
    border-radius: 0 0 8px 8px;
    border: 1px solid rgba(191, 219, 254, 0.9);
    border-top: none;
    padding: 6px 6px 6px;
    margin-top: 0;
}

/* more compact grid, 3–4 rows */
.hosp-patient-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 4px 6px;
}

.hosp-patient-grid label span {
    font-size: 10px;
}


.hidden {
    display: none;
}

/* Modal backdrop + window for Add procedure */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal-backdrop.hidden {
    display: none;
}

.modal {
    background: linear-gradient(145deg, var(--bg-card), rgba(248, 250, 252, 0.98));
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-soft);
    padding: 10px 12px;
    width: min(420px, 100% - 24px);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
}

.modal-close {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 4px;
}

.modal-form-two-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.modal-form-two-col .full-width {
    grid-column: 1 / -1;
}

@media (max-width: 480px) {
    .modal-form-two-col {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Treatment plan header: title + button inline */

.treatment-plan-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.nav-alarm {
    display: inline-block;
    margin-left: 4px;
    font-size: 11px;
    color: #f97316; /* orange dot as alarm */
}

.tab-alarm {
    display: inline-block;
    margin-left: 4px;
    font-size: 11px;
    color: #f97316; /* small orange dot */
}


.report-sections details {
    margin-bottom: 6px;
    border-radius: 8px;
    border: 1px solid rgba(209, 213, 219, 0.9);
    background: #ffffff;
}

.report-sections summary {
    padding: 4px 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 12px;
}

.report-block {
    padding: 4px 6px 6px;
    font-size: 11px;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.report-table th,
.report-table td {
    border: 1px solid rgba(209, 213, 219, 0.9);
    padding: 2px 4px;
}

@media print {
    .top-bar,
    .flash-container,
    .btn {
        display: none !important;
    }
    .glass.card {
        box-shadow: none;
        background: #ffffff;
        border-radius: 0;
    }
}

.icon-btn.note-flag {
    border: none;
    background: transparent;
    color: #ef4444;
    font-weight: 700;
    cursor: pointer;
    margin-left: 4px;
    padding: 0 3px;
    font-size: 12px;
}

.icon-btn.note-flag:hover {
    text-shadow: 0 0 2px rgba(239, 68, 68, 0.7);
}

.icon-btn {
    background: transparent;
    border: none;
    padding: 0;
    margin-left: 4px;
    cursor: pointer;
    line-height: 1;
    display: inline-block;
    align-items: center;
    justify-content: center;
    vertical-align: text-bottom;  /* align with text baseline */

}

.icon-btn:focus {
    outline: none;
}

.warn-icon {
    width: 14px;   /* small & compact */
    height: 14px;
    display: block;
    position: relative;
    top: -2px;
}
