/* Real Estate Agent System - Main Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Athiti:wght@400;500;600;700&display=swap');
@import url('https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css');

:root {
    --primary: #ff7043;
    --primary-dark: #d84315;
    --primary-light: #ffab91;
    --secondary: #1976d2;
    --success: #4caf50;
    --danger: #f44336;
    --warning: #ff9800;
    --info: #2196f3;
    --light: #f5f5f5;
    --dark: #212121;
    --text: #333333;
    --text-light: #666666;
    --border: #e0e0e0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s ease;
    --f7-theme-color: #ff7043;
    --f7-theme-color-rgb: 255, 112, 67;
    --f7-font-family: 'Athiti', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --f7-bars-bg-color: rgba(255, 255, 255, 0.9);
    --f7-page-bg-color: #f3f6fb;
    --f7-navbar-large-title-font-size: 1.8rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: 'Athiti', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
}

body {
    background-color: var(--light);
}

.app-layout {
    padding-bottom: 6.75rem;
}

/* Containers & Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

.container-fluid {
    width: 100%;
    padding: 0 15px;
    margin: 0 auto;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0.5rem;
    color: var(--dark);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: 1rem;
    color: var(--text);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-family: 'Athiti', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    white-space: nowrap;
    user-select: none;
}

.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

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

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

.btn-secondary {
    background-color: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background-color: #1565c0;
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-success:hover {
    background-color: #45a049;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #da190b;
}

.btn-outline {
    background-color: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background-color: var(--primary);
    color: white;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-block {
    display: block;
    width: 100%;
}

/* Cards */
.card {
    background-color: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}

.card.form-card,
.card.form-card .card-body {
    overflow: visible;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.card-header {
    padding: 1.5rem;
    background-color: var(--light);
    border-bottom: 1px solid var(--border);
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1.5rem;
    background-color: var(--light);
    border-top: 1px solid var(--border);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--dark);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="tel"],
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: 'Athiti', sans-serif;
    font-size: 1rem;
    transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 112, 67, 0.1);
}

textarea {
    resize: vertical;
    min-height: 120px;
}

.select2-container {
    width: 100% !important;
    display: block;
    font-family: 'Athiti', sans-serif;
    font-size: 1rem;
}

.select2-container--default .select2-selection--single {
    display: flex;
    align-items: center;
    height: 3rem;
    min-height: 3rem;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    display: block;
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    padding: 0 0.75rem;   /* ซ้าย-ขวาเท่ากัน */
    text-align: left;
    color: var(--text);
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: calc(3rem - 2px);
    right: 0.35rem;
}

.select2-container--default .select2-selection--single .select2-selection__clear {
    height: calc(3rem - 2px);
    margin-right: 0.5rem;   /* ลดระยะห่าง */
    position: absolute;     /* ให้อยู่ชิดขอบขวา */
    right: 0.5rem;            /* กำหนดตำแหน่งชัดเจน */
    display: inline-flex;
    align-items: center;
    color: var(--text-light);
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #8a8a8a;
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 112, 67, 0.1);
}

.select2-dropdown {
    border-color: var(--border);
    font-family: 'Athiti', sans-serif;
    z-index: 5000;
}

.select2-container--open,
.select2-container--open .select2-dropdown {
    z-index: 5000;
}

.select2-floating {
    position: relative;
    z-index: 20;
}

.select2-floating:focus-within {
    z-index: 5001;
}

.owner-select-control {
    display: block;
    position: relative;
    min-height: 2.85rem;
}

.owner-select-control .select2-container {
    display: block !important;
    position: relative !important;
    top: auto !important;
    left: auto !important;
    width: 100% !important;
    height: 2.85rem !important;
}

.owner-select-control .select2-selection--single {
    height: 2.85rem !important;
}

.owner-select-control .select2-selection__rendered {
    height: auto !important;
    min-height: 0 !important;
    line-height: 1.25 !important;
}

.select2-help-text {
    margin: 0.65rem 0 0;
    color: #666;
    line-height: 1.35;
}

.select2-results__option {
    padding: 0.55rem 0.75rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.select2-search--dropdown .select2-search__field {
    min-height: 2.65rem;
    padding: 0.55rem 0.7rem;
    line-height: 1.3;
}

.owner-preview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fafafa;
}

.owner-preview span {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
    color: var(--text-light);
}

.owner-preview strong {
    color: var(--dark);
    overflow-wrap: anywhere;
}

.property-upload-box {
    padding: 1rem;
    border: 1px dashed var(--border);
    border-radius: 4px;
    background: #fafafa;
}

.property-upload-box input[type="file"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: white;
    font-family: 'Athiti', sans-serif;
}

.property-upload-box p {
    margin: 0.5rem 0 0;
    color: var(--text-light);
}

.property-image-preview,
.property-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.property-image-preview:empty {
    display: none;
}

.property-image-preview figure,
.property-gallery-grid figure {
    position: relative;
    min-width: 0;
    aspect-ratio: 4 / 3;
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #f8f8f8;
}

.property-image-preview img,
.property-gallery-grid img,
.record-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.property-image-preview figcaption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0.25rem 0.45rem;
    color: white;
    background: rgba(0, 0, 0, 0.62);
    font-size: 0.75rem;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.property-image-remove {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border: 0;
    border-radius: 4px;
    color: white;
    background: rgba(244, 67, 54, 0.92);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}

.property-image-remove:hover {
    background: var(--danger);
}

.thai-address-widget {
    grid-column: 1 / -1;
}

.thai-address-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1.5rem;
}

.thai-address-select {
    width: 100%;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
}

.table thead {
    background-color: var(--light);
    border-bottom: 2px solid var(--border);
}

.table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--dark);
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.table tbody tr:hover {
    background-color: #fafafa;
}

/* Navigation */
.app-header {
    background-color: white;
    box-shadow: var(--shadow);
    padding: 0.875rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    text-decoration: none;
}

.nav-brand:hover {
    color: var(--primary-dark);
    text-decoration: none;
}

.nav-brand span {
    color: var(--text-light);
    font-size: 0.825rem;
    font-weight: 600;
}

.top-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.4rem;
    min-width: 0;
}

.top-actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.35rem;
    height: 2.35rem;
    color: var(--text-light);
    border: 1px solid transparent;
    border-radius: 4px;
    text-decoration: none;
}

.top-actions a:hover,
.top-actions a.active {
    color: var(--primary-dark);
    background-color: rgba(255, 112, 67, 0.1);
    border-color: rgba(255, 112, 67, 0.2);
    text-decoration: none;
}

.top-user-name {
    max-width: 12rem;
    color: var(--dark);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-menu a {
    color: var(--text);
    font-weight: 500;
    padding: 0.5rem 0;
    border-bottom: 2px solid transparent;
}

.nav-menu a:hover,
.nav-menu a.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    text-decoration: none;
}

/* Bottom Navigation */
.bottom-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    display: flex;
    justify-content: center;
    background: white;
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.12);
}

.bottom-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 840px;
    margin: 0 auto;
    padding: 0.65rem 1rem calc(0.65rem + env(safe-area-inset-bottom));
}

.bottom-nav a {
    display: inline-flex;
    position: relative;
    width: 3.4rem;
    height: 3.4rem;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--text-light);
    border-top: 3px solid transparent;
    border-radius: 4px;
    text-decoration: none;
    transition: var(--transition);
}

.bottom-nav a i {
    font-size: 1.25rem;
}

.bottom-nav a span {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 0.55rem);
    z-index: 210;
    transform: translateX(-50%) translateY(0.25rem);
    padding: 0.35rem 0.6rem;
    color: white;
    background-color: var(--dark);
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    transition: var(--transition);
}

.bottom-nav a:hover span,
.bottom-nav a:focus span {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.bottom-nav a:hover,
.bottom-nav a.active {
    background-color: rgba(255, 112, 67, 0.1);
    border-top-color: var(--primary);
    color: var(--primary-dark);
    text-decoration: none;
}

/* Main Content */
.main-content {
    padding: 2rem 2rem 1rem;
}

.app-footer {
    text-align: center;
    padding: 2rem;
    background-color: white;
    margin-top: 4rem;
    border-top: 1px solid #eee;
}

/* Record Cards */
.record-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    gap: 0.85rem;
    align-items: stretch;
}

.record-card {
    min-width: 0;
}

.record-card .card-body {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 1.1rem;
}

.record-cover {
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
    background: #f8f8f8;
}

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

.record-head h3 {
    margin: 0;
    font-size: 1.12rem;
    overflow-wrap: anywhere;
}

.record-head p {
    margin: 0.25rem 0 0;
    color: var(--text-light);
    overflow-wrap: anywhere;
}

.record-meta,
.record-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.record-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
    color: var(--text-light);
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}

.record-actions {
    justify-content: flex-end;
    margin-top: auto;
}

.kv-grid {
    display: grid;
    grid-template-columns: minmax(8rem, 0.45fr) 1fr;
    gap: 0.75rem 1rem;
}

.kv-grid span {
    color: var(--text-light);
}

.kv-grid strong {
    font-weight: 600;
    color: var(--dark);
    overflow-wrap: anywhere;
}

/* Appointment Calendar */
.calendar-page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.appointments-grid {
    width: 100%;
    display: block;
}

@media (max-width: 1024px) {
    .appointments-grid {
        width: 100%;
    }
}

.summary-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.06);
    padding: 1.35rem;
}

.summary-card-secondary {
    background: #fafafa;
}

.summary-card-title {
    margin: 0;
    font-size: 0.96rem;
    font-weight: 700;
    color: var(--dark);
}

.summary-card-value {
    margin: 0.75rem 0 0;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-dark);
    line-height: 1;
}

.summary-metrics {
    display: grid;
    gap: 0.75rem;
    margin-top: 1rem;
}

.summary-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    color: var(--text-light);
    font-size: 0.95rem;
}

.summary-metric strong {
    color: var(--dark);
}

.summary-card-footer {
    margin-top: 1.25rem;
    text-align: right;
}

.summary-card-footer .btn {
    width: 100%;
}

.calendar-page-head h1 {
    font-size: clamp(1.75rem, 2.6vw, 2.4rem);
}

.calendar-page-head p {
    margin-top: 0.45rem;
    color: var(--text-light);
}

.thai-calendar-shell {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 1px solid #e8eaed;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(32, 33, 35, 0.08);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.calendar-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-bottom: 1px solid #e8eaed;
}

.calendar-title {
    text-align: center;
    min-width: 0;
    flex: 1;
}

.calendar-title h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a1a;
    letter-spacing: -0.02em;
}

.calendar-toolbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
}

.calendar-toolbar .btn {
    min-width: 2.75rem;
    padding: 0.5rem;
    background: #f0f1f3;
    border: 1px solid #dadce0;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #202124;
    cursor: pointer;
    transition: all 0.2s ease;
}

.calendar-toolbar .btn:active {
    background: #e8eaed;
}

.thai-calendar {
    width: 100%;
    background: #ffffff;
}

.calendar-weekdays,
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays {
    background: #f8f9fa;
    border-bottom: 1px solid #e8eaed;
    padding: 0;
    margin: 0;
}

.calendar-weekdays div {
    padding: 0.65rem 0.5rem;
    color: #5f6368;
    font-weight: 700;
    text-align: center;
    font-size: 0.8rem;
    border-right: 1px solid #e8eaed;
    letter-spacing: 0.5px;
}

.calendar-weekdays div:last-child {
    border-right: none;
}

.calendar-grid {
    background: #ffffff;
    gap: 0;
    padding: 0;
}

.calendar-day {
    display: flex;
    flex-direction: column;
    min-height: 7.5rem;
    padding: 0.6rem;
    border-right: 1px solid #e8eaed;
    border-bottom: 1px solid #e8eaed;
    background: #ffffff;
    color: #202124;
    font-family: 'Athiti', sans-serif;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.calendar-day:nth-child(7n) {
    border-right: none;
}

.calendar-day:nth-last-child(-n+7) {
    border-bottom: none;
}

.calendar-day:not(.is-empty):active {
    background: #e8f0fe;
}

.calendar-day.is-empty {
    background: #f8f9fa;
    cursor: default;
}

.calendar-day.is-today {
    background: linear-gradient(135deg, #e8f0fe 0%, #f0f4ff 100%);
    border-right-color: #d2d3d4;
    border-bottom-color: #d2d3d4;
}

.calendar-day.is-today .day-number {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.day-number {
    display: inline-block;
    width: 1.8rem;
    height: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.4rem;
    border-radius: 6px;
    font-weight: 700;
    color: #202124;
    font-size: 0.85rem;
    background: transparent;
}

.appointment-stack {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
    max-height: 5.5rem;
    overflow-y: auto;
    flex: 1;
}

.appointment-chip {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    width: 100%;
    padding: 0.3rem 0.4rem;
    border-left: 3px solid #3b82f6;
    border-radius: 3px;
    background: #e3f2fd;
    color: #1565c0;
    font-family: 'Athiti', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.appointment-chip:active {
    background: #bbdefb;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}


.appointment-chip {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    width: 100%;
    min-height: 1.65rem;
    padding: 0.2rem 0.45rem;
    border-left: 3px solid var(--secondary);
    border-top: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: 4px;
    background: rgba(25, 118, 210, 0.1);
    color: #0d47a1;
    font-family: 'Athiti', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.2;
    min-width: 0;
    cursor: pointer;
    text-align: left;
}

.appointment-chip:hover,
.appointment-chip:focus {
    outline: none;
    filter: brightness(0.96);
    box-shadow: inset 0 0 0 1px currentColor;
}

.appointment-chip-confirmed {
    border-left-color: var(--success);
    background: rgba(76, 175, 80, 0.12);
    color: #1b5e20;
}

.appointment-chip-done {
    border-left-color: #607d8b;
    background: rgba(96, 125, 139, 0.14);
    color: #263238;
}

.appointment-chip-cancelled {
    border-left-color: var(--danger);
    background: rgba(244, 67, 54, 0.12);
    color: #b71c1c;
}

.appointment-notification-toast {
    max-width: min(24rem, calc(100vw - 2rem));
}

.appointment-notification-toast .swal2-title {
    font-size: 1rem;
    line-height: 1.3;
}

.appointment-notification-toast .swal2-html-container {
    margin: 0.35rem 0 0;
}

.appointment-notification-alert {
    text-align: left;
    line-height: 1.45;
}

.appointment-notification-alert strong {
    display: block;
    margin-bottom: 0.2rem;
    color: var(--dark);
}

.chip-time {
    flex: 0 0 auto;
    color: inherit;
    opacity: 0.82;
}

.chip-title {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-more {
    color: var(--text-light);
    font-size: 0.82rem;
    font-weight: 700;
}

body.modal-open {
    overflow: hidden;
}

.appointment-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(33, 33, 33, 0.48);
}

.appointment-modal-backdrop[hidden] {
    display: none;
}

.appointment-modal {
    width: min(760px, 100%);
    max-height: min(90vh, 760px);
    overflow: hidden;
    border-radius: 8px;
    background: white;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

.appointment-form {
    display: flex;
    flex-direction: column;
    max-height: min(90vh, 760px);
}

.appointment-modal-header,
.appointment-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
}

.appointment-modal-header {
    border-bottom: 1px solid var(--border);
}

.appointment-modal-header h3 {
    margin: 0;
}

.appointment-modal-header p {
    margin: 0.25rem 0 0;
    color: var(--text-light);
    font-weight: 600;
}

.appointment-modal-body {
    overflow-y: auto;
    padding: 1.25rem;
}

.appointment-reminder-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(12rem, 0.45fr);
    gap: 1rem;
    align-items: end;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fafafa;
}

.appointment-reminder-panel .form-group {
    margin-bottom: 0;
}

.appointment-reminder-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0 0.45rem;
    color: var(--dark);
    cursor: pointer;
}

.appointment-reminder-toggle input {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--primary);
}

.appointment-modal-footer {
    flex-direction: column;
    gap: 0.75rem;
    border-top: 1px solid var(--border);
    background: #fafafa;
}

.appointment-modal-footer .btn {
    width: 100%;
    margin: 0;
}

.modal-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.35rem;
    height: 2.35rem;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--text-light);
    cursor: pointer;
    transition: var(--transition);
}

.modal-icon-button:hover,
.modal-icon-button:focus {
    color: var(--primary-dark);
    background: rgba(255, 112, 67, 0.1);
    border-color: rgba(255, 112, 67, 0.2);
    outline: none;
}

/* Grid */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Alerts & Messages */
.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    border-left: 4px solid;
}

.alert-success {
    background-color: #c8e6c9;
    border-color: var(--success);
    color: #1b5e20;
}

.alert-danger {
    background-color: #ffcdd2;
    border-color: var(--danger);
    color: #b71c1c;
}

.alert-warning {
    background-color: #fff3e0;
    border-color: var(--warning);
    color: #e65100;
}

.alert-info {
    background-color: #e3f2fd;
    border-color: var(--info);
    color: #01579b;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
}

.badge-primary {
    background-color: var(--primary);
    color: white;
}

.badge-success {
    background-color: var(--success);
    color: white;
}

.badge-danger {
    background-color: var(--danger);
    color: white;
}

.badge-warning {
    background-color: var(--warning);
    color: white;
}

.badge-info {
    background-color: var(--info);
    color: white;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.pagination a,
.pagination span {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
}

.pagination a:hover {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
    text-decoration: none;
}

.pagination .active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Search Highlight */
.highlight {
    background-color: #fff176;
    color: #3d3000;
    padding: 0.05rem 0.18rem;
    border-radius: 2px;
    font-weight: 600;
}

/* Status Indicators */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
}

.status-active {
    background-color: #c8e6c9;
    color: #1b5e20;
}

.status-inactive {
    background-color: #f5f5f5;
    color: #757575;
}

.status-completed {
    background-color: #c8e6c9;
    color: #1b5e20;
}

.status-pending {
    background-color: #fff3e0;
    color: #e65100;
}

.status-cancelled {
    background-color: #ffcdd2;
    color: #b71c1c;
}

/* Premium mobile app theme */
:root {
    --app-bg: #f3f6fb;
    --app-surface: rgba(255, 255, 255, 0.94);
    --app-surface-solid: #ffffff;
    --app-ink: #18202a;
    --app-muted: #667085;
    --app-line: rgba(137, 150, 170, 0.24);
    --app-shadow: 0 14px 40px rgba(17, 24, 39, 0.08);
    --app-shadow-strong: 0 20px 55px rgba(17, 24, 39, 0.14);
}

body.app-layout {
    min-height: 100%;
    background:
        radial-gradient(circle at 12% 0%, rgba(255, 112, 67, 0.14), transparent 24rem),
        radial-gradient(circle at 100% 12%, rgba(25, 118, 210, 0.12), transparent 24rem),
        var(--app-bg);
    color: var(--app-ink);
}

body.framework7-shell {
    padding-bottom: 0;
    overflow: hidden;
}

.framework7-shell #app,
.framework7-shell .view-main,
.framework7-shell .page {
    background: transparent;
}

.framework7-shell a.link:hover {
    text-decoration: none;
}

.framework7-shell .page-content.main-content {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0 0 calc(var(--f7-toolbar-height, 56px) + 1.3rem + env(safe-area-inset-bottom));
}

.framework7-shell .f7-app-navbar {
    color: var(--app-ink);
}

.framework7-shell .f7-app-navbar .navbar-bg {
    border-bottom: 1px solid rgba(137, 150, 170, 0.18);
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 12px 35px rgba(17, 24, 39, 0.08);
    backdrop-filter: blur(18px);
}

.framework7-shell .f7-app-navbar .title {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.05rem;
    color: var(--app-ink);
    font-weight: 700;
    line-height: 1.05;
}

.framework7-shell .f7-app-navbar .title span {
    color: var(--app-muted);
    font-size: 0.72rem;
    font-weight: 600;
}

.framework7-shell .f7-app-navbar .title-large-text {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    color: var(--app-ink);
    letter-spacing: 0;
}

.framework7-shell .f7-app-navbar .title-large-text small {
    color: var(--app-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.framework7-shell .app-brand-link,
.framework7-shell .f7-app-navbar .top-actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.35rem;
    height: 2.35rem;
    border: 1px solid var(--app-line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--app-muted);
    box-shadow: 0 8px 18px rgba(17, 24, 39, 0.05);
}

.framework7-shell .app-brand-link,
.framework7-shell .f7-app-navbar .top-actions a.active,
.framework7-shell .f7-app-navbar .top-actions a:hover {
    color: var(--primary-dark);
    background: rgba(255, 112, 67, 0.12);
    border-color: rgba(255, 112, 67, 0.24);
}

.framework7-shell .f7-app-navbar .top-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.framework7-shell .f7-main-menu {
    width: min(22rem, 88vw);
    background: var(--app-bg);
}

.framework7-shell .f7-main-menu .page,
.framework7-shell .f7-main-menu .page-content {
    background:
        linear-gradient(180deg, rgba(255, 112, 67, 0.12), transparent 10rem),
        var(--app-bg);
}

.framework7-shell .f7-main-menu .page-content {
    padding: calc(1rem + env(safe-area-inset-top)) 0 calc(1rem + env(safe-area-inset-bottom));
}

.framework7-shell .menu-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.35rem 1rem 0.75rem;
}

.framework7-shell .menu-panel-head strong,
.framework7-shell .menu-panel-head span {
    display: block;
}

.framework7-shell .menu-panel-head strong {
    color: var(--app-ink);
    font-size: 1.25rem;
    line-height: 1.1;
}

.framework7-shell .menu-panel-head span {
    margin-top: 0.2rem;
    color: var(--app-muted);
    font-size: 0.92rem;
    font-weight: 600;
}

.framework7-shell .menu-panel-head .panel-close {
    width: 2.35rem;
    height: 2.35rem;
    border: 1px solid var(--app-line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.78);
    color: var(--app-muted);
}

.framework7-shell .f7-main-menu .block-title {
    margin-top: 1rem;
    color: var(--app-muted);
    font-weight: 700;
}

.framework7-shell .menu-panel-list {
    margin-top: 0.35rem;
    margin-bottom: 0.5rem;
}

.framework7-shell .menu-panel-list ul {
    margin: 0 0.75rem;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.74);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 12px 30px rgba(17, 24, 39, 0.08);
}

.framework7-shell .menu-panel-list .item-content {
    min-height: 3rem;
    color: var(--app-ink);
}

.framework7-shell .menu-panel-list .item-media {
    justify-content: center;
    width: 2rem;
    color: var(--app-muted);
}

.framework7-shell .menu-panel-list .item-title {
    font-weight: 700;
}

.framework7-shell .menu-panel-list .item-content.active {
    background: rgba(255, 112, 67, 0.12);
    color: var(--primary-dark);
}

.framework7-shell .menu-panel-list .item-content.active .item-media {
    color: var(--primary-dark);
}

.framework7-shell .f7-bottom-tabbar {
    height: auto;
    padding: 0 0.7rem calc(0.65rem + env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(243, 246, 251, 0.98), rgba(243, 246, 251, 0));
}

.framework7-shell .f7-bottom-tabbar::before {
    display: none;
}

.framework7-shell .f7-bottom-tabbar .toolbar-inner {
    position: relative;
    justify-content: flex-start;
    gap: 0.2rem;
    width: 100%;
    max-width: 920px;
    height: auto;
    min-height: 4rem;
    margin: 0 auto;
    padding: 0.45rem;
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.68);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 18px 45px rgba(17, 24, 39, 0.16);
    backdrop-filter: blur(16px);
    scrollbar-width: none;
}

.framework7-shell .f7-bottom-tabbar .toolbar-inner::-webkit-scrollbar {
    display: none;
}

.framework7-shell .f7-bottom-tabbar .tab-link {
    flex: 0 0 auto;
    min-width: 5.15rem;
    height: 3.1rem;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--app-muted);
    font-weight: 700;
}

.framework7-shell .f7-bottom-tabbar .tab-link i {
    font-size: 1.12rem;
}

.framework7-shell .f7-bottom-tabbar .tab-link-active,
.framework7-shell .f7-bottom-tabbar .tab-link:hover {
    border-color: rgba(255, 112, 67, 0.2);
    background: rgba(255, 112, 67, 0.12);
    color: var(--primary-dark);
}

.framework7-shell .app-footer {
    max-width: 1180px;
    margin: 1.25rem auto 0;
    padding: 0.5rem 1rem 1rem;
    background: transparent;
    border-top: 0;
    text-align: center;
}

.framework7-shell .app-footer p {
    margin: 0;
    color: var(--app-muted);
    font-size: 0.86rem;
}

.app-page-block {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 clamp(0.85rem, 3vw, 1.4rem);
}

.app-page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.app-page-head h1 {
    margin: 0;
}

.app-page-head p {
    margin: 0.25rem 0 0;
    color: var(--app-muted);
}

.app-page-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.6rem;
}

.app-filter-card {
    margin: 0 0 1.1rem;
}

.app-filter-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: end;
}

.app-filter-grid.with-status {
    grid-template-columns: minmax(0, 1fr) minmax(11rem, 0.35fr) auto;
}

.app-list-card .card-content,
.app-stat-card .card-content,
.app-filter-card .card-content {
    padding: 1.1rem;
}

.app-stat-card {
    height: 100%;
}

.app-stat-card .card-content {
    display: grid;
    gap: 0.65rem;
    text-align: center;
}

.app-stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.8rem;
    height: 2.8rem;
    margin: 0 auto 0.15rem;
    border-radius: 8px;
    background: rgba(255, 112, 67, 0.12);
    color: var(--primary-dark);
    font-size: 1.35rem;
}

.app-stat-label {
    margin: 0;
    color: var(--app-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.app-stat-value {
    margin: 0;
    color: var(--app-ink);
    font-size: clamp(1.35rem, 3vw, 1.8rem);
}

.app-action-list {
    margin: 0;
}

.app-action-list ul {
    border-radius: 8px;
}

.app-action-list .item-media {
    color: var(--primary-dark);
    min-width: 2rem;
}

.app-layout .container-fluid,
.app-layout .container {
    max-width: 1180px;
    padding-left: clamp(0.85rem, 3vw, 1.4rem);
    padding-right: clamp(0.85rem, 3vw, 1.4rem);
}

.app-layout .main-content {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: clamp(1rem, 3vw, 1.6rem) clamp(0.85rem, 3vw, 1.4rem) 1rem;
}

.app-layout .app-header {
    position: sticky;
    top: 0;
    z-index: 300;
    padding: calc(0.65rem + env(safe-area-inset-top)) 0 0.65rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.65);
    background: rgba(255, 255, 255, 0.84);
    box-shadow: 0 12px 35px rgba(17, 24, 39, 0.08);
    backdrop-filter: blur(18px);
}

.app-layout .app-header nav {
    min-height: 3rem;
    gap: 1rem;
}

.app-layout .nav-brand {
    color: var(--app-ink);
    font-size: clamp(1.08rem, 2.5vw, 1.35rem);
    line-height: 1.05;
}

.app-layout .nav-brand span {
    color: var(--app-muted);
    font-size: 0.78rem;
}

.app-layout .top-actions {
    gap: 0.35rem;
}

.app-layout .top-actions a {
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--app-line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--app-muted);
    box-shadow: 0 8px 18px rgba(17, 24, 39, 0.05);
}

.app-layout .top-actions a:hover,
.app-layout .top-actions a.active {
    color: var(--primary-dark);
    background: rgba(255, 112, 67, 0.12);
    border-color: rgba(255, 112, 67, 0.24);
}

.app-layout .bottom-bar {
    padding: 0 0.7rem calc(0.65rem + env(safe-area-inset-bottom));
    border-top: 0;
    background: linear-gradient(to top, rgba(243, 246, 251, 0.98), rgba(243, 246, 251, 0));
    box-shadow: none;
}

.app-layout .bottom-nav {
    max-width: 840px;
    padding: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.68);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 18px 45px rgba(17, 24, 39, 0.16);
    backdrop-filter: blur(16px);
}

.app-layout .bottom-nav a {
    border-top: 0;
    border: 1px solid transparent;
    border-radius: 8px;
}

.app-layout .bottom-nav a:hover,
.app-layout .bottom-nav a.active {
    border-color: rgba(255, 112, 67, 0.2);
    background: rgba(255, 112, 67, 0.12);
}

.app-layout h1 {
    color: var(--app-ink);
    font-size: clamp(1.55rem, 4vw, 2.25rem);
    letter-spacing: 0;
}

.app-layout h2 {
    font-size: clamp(1.3rem, 3vw, 1.8rem);
}

.app-layout h3 {
    font-size: clamp(1.08rem, 2.4vw, 1.35rem);
}

.app-layout p,
.app-layout .record-head p,
.app-layout .record-meta span,
.app-layout .kv-grid span {
    color: var(--app-muted);
}

.app-layout .card,
.app-layout .thai-calendar-shell,
.app-layout .appointment-modal {
    border: 1px solid rgba(255, 255, 255, 0.78);
    border-radius: 8px;
    background: var(--app-surface);
    box-shadow: var(--app-shadow);
    backdrop-filter: blur(10px);
}

.app-layout .card:hover {
    box-shadow: var(--app-shadow-strong);
    transform: translateY(-1px);
}

.app-layout .card-header,
.app-layout .card-footer,
.app-layout .appointment-modal-footer {
    border-color: var(--app-line);
    background: rgba(248, 250, 253, 0.88);
}

.app-layout .card-header h4,
.app-layout .card-header h3 {
    color: var(--app-ink);
}

.app-layout .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 2.65rem;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(17, 24, 39, 0.08);
}

.app-layout .btn:hover {
    transform: translateY(-1px);
}

.app-layout .btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.app-layout .btn-secondary {
    background: linear-gradient(135deg, var(--secondary), #0d47a1);
}

.app-layout .btn-outline {
    border: 1px solid rgba(255, 112, 67, 0.36);
    background: rgba(255, 255, 255, 0.75);
}

.app-layout input[type="text"],
.app-layout input[type="email"],
.app-layout input[type="password"],
.app-layout input[type="number"],
.app-layout input[type="date"],
.app-layout input[type="datetime-local"],
.app-layout input[type="tel"],
.app-layout select,
.app-layout textarea,
.app-layout .property-upload-box input[type="file"] {
    min-height: 2.85rem;
    border: 1px solid rgba(137, 150, 170, 0.34);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--app-ink);
}

.app-layout input:focus,
.app-layout select:focus,
.app-layout textarea:focus {
    border-color: rgba(25, 118, 210, 0.62);
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.12);
}

.app-layout label {
    color: #263241;
    font-size: 0.96rem;
}

.app-layout .select2-container--default .select2-selection--single {
    height: 2.85rem;
    min-height: 2.85rem;
    border-color: rgba(137, 150, 170, 0.34);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.88);
}

.app-layout .select2-container--default .select2-selection--single .select2-selection__rendered,
.app-layout .select2-container--default .select2-selection--single .select2-selection__arrow,
.app-layout .select2-container--default .select2-selection--single .select2-selection__clear {
    min-height: calc(2.85rem - 2px);
}

.app-layout .select2-container--default .select2-selection--single .select2-selection__rendered {
    height: auto;
    min-height: 0;
    color: var(--app-ink);
    line-height: 1.25;
}

.app-layout .table {
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    border: 1px solid var(--app-line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.82);
}

.app-layout .table thead {
    background: rgba(248, 250, 253, 0.9);
}

.app-layout .table th,
.app-layout .table td {
    border-bottom-color: var(--app-line);
}

.app-layout .record-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
}

.app-layout .record-card .card-body {
    padding: 1rem;
}

.app-layout .record-head h3 {
    color: var(--app-ink);
}

.app-layout .record-actions {
    gap: 0.45rem;
}

.app-layout .badge,
.app-layout .status-badge {
    border-radius: 8px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.app-layout .alert {
    border: 1px solid transparent;
    border-left-width: 4px;
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(17, 24, 39, 0.06);
}

.app-layout .pagination a,
.app-layout .pagination span {
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.82);
}

.app-layout .calendar-page-head {
    margin-bottom: 1.2rem;
}

.app-layout .calendar-toolbar {
    background: linear-gradient(135deg, rgba(255, 112, 67, 0.12), rgba(25, 118, 210, 0.1));
}

.app-layout .calendar-day {
    background: rgba(255, 255, 255, 0.92);
}

.app-layout .calendar-day.has-appointments {
    background: rgba(250, 253, 255, 0.96);
}

.app-layout .appointment-modal-backdrop {
    background: rgba(17, 24, 39, 0.44);
    backdrop-filter: blur(6px);
}

.app-layout .appointment-reminder-panel,
.app-layout .owner-preview,
.app-layout .property-upload-box {
    border-color: var(--app-line);
    border-radius: 8px;
    background: rgba(248, 250, 253, 0.88);
}

@media (max-width: 768px) {
    body.app-layout {
        background:
            linear-gradient(180deg, rgba(24, 32, 42, 0.04), rgba(243, 246, 251, 0) 15rem),
            var(--app-bg);
    }

    .framework7-shell .page-content.main-content {
        padding-top: 0.75rem;
    }

    .framework7-shell .f7-app-navbar .top-actions {
        flex: 0 1 auto;
        max-width: 52vw;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .framework7-shell .f7-app-navbar .top-actions::-webkit-scrollbar {
        display: none;
    }

    .framework7-shell .f7-app-navbar .top-actions a {
        flex: 0 0 auto;
    }

    .app-page-block {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

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

    .app-page-actions {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
        width: 100%;
    }

    .app-page-actions .btn,
    .app-page-actions .button {
        width: 100%;
    }

    .app-filter-grid,
    .app-filter-grid.with-status {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .app-layout .main-content {
        padding: 0.95rem 0.85rem 1rem;
    }

    .app-layout .container-fluid,
    .app-layout .container {
        padding-left: 0;
        padding-right: 0;
    }

    .app-layout .app-header {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

    .app-layout .app-header nav {
        gap: 0.55rem;
    }

    .app-layout .top-actions {
        flex: 0 1 auto;
        max-width: 62vw;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .app-layout .top-actions::-webkit-scrollbar {
        display: none;
    }

    .app-layout .top-actions a {
        width: 2.35rem;
        height: 2.35rem;
        flex: 0 0 auto;
    }

    .app-layout .card,
    .app-layout .thai-calendar-shell {
        margin-bottom: 0.85rem;
    }

    .app-layout .card-body,
    .app-layout .card-header,
    .app-layout .card-footer {
        padding: 0.95rem;
    }

    .app-layout .record-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .app-layout .record-actions {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
        width: 100%;
    }

    .app-layout .record-actions .btn {
        width: 100%;
    }

    .app-layout .kv-grid {
        grid-template-columns: 1fr;
        gap: 0.2rem;
    }

    .app-layout .table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .app-layout form.card > .card-body[style*="display: flex"],
    .app-layout form.card > .card-body[style*="display: grid"] {
        display: grid !important;
        grid-template-columns: 1fr !important;
        align-items: stretch !important;
    }
}

@media (max-width: 576px) {
    .app-layout {
        padding-bottom: 6.85rem;
    }

    body.framework7-shell {
        padding-bottom: 0;
    }

    .framework7-shell .f7-app-navbar .title {
        font-size: 1rem;
    }

    .framework7-shell .f7-bottom-tabbar {
        padding-left: 0.45rem;
        padding-right: 0.45rem;
    }

    .framework7-shell .f7-bottom-tabbar .tab-link {
        min-width: 3.35rem;
        height: 3rem;
    }

    .framework7-shell .f7-bottom-tabbar .tabbar-label {
        display: none;
    }

    .app-layout .bottom-bar {
        padding-left: 0.45rem;
        padding-right: 0.45rem;
    }

    .app-layout .bottom-nav {
        justify-content: space-between;
        gap: 0.15rem;
        padding: 0.45rem;
    }

    .app-layout .bottom-nav a {
        width: clamp(1.9rem, 9.2vw, 2.65rem);
        height: 2.85rem;
    }

    .app-layout .bottom-nav a span {
        display: none;
    }

    .app-layout .btn {
        min-height: 2.55rem;
    }

    .app-layout .calendar-day {
        min-height: 5rem;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }

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

    .calendar-page-head .btn,
    .calendar-toolbar .btn {
        width: 100%;
    }

    .calendar-toolbar-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }

    .calendar-title h2 {
        font-size: 1.35rem;
    }

    .calendar-day {
        min-height: 6.5rem;
        padding: 0.45rem;
    }

    .day-number {
        width: 1.65rem;
        height: 1.65rem;
        margin-bottom: 0.3rem;
        font-size: 0.95rem;
    }

    .appointment-chip {
        min-height: 1.35rem;
        padding: 0.15rem 0.3rem;
        font-size: 0.74rem;
    }

    .chip-time {
        display: none;
    }

    .appointment-modal {
        max-height: calc(100vh - 2rem);
    }

    .appointment-form {
        max-height: calc(100vh - 2rem);
    }

    .appointment-reminder-panel {
        grid-template-columns: 1fr;
        align-items: stretch;
    }
    
    .nav-menu {
        flex-direction: column;
        gap: 0;
    }
    
    .bottom-nav {
        justify-content: center;
        gap: clamp(0.1rem, 0.65vw, 0.35rem);
        padding-left: clamp(0.25rem, 1.6vw, 0.5rem);
        padding-right: clamp(0.25rem, 1.6vw, 0.5rem);
    }

    .bottom-nav a {
        flex: 0 0 auto;
        width: clamp(1.75rem, 9.4vw, 3rem);
        height: clamp(2.7rem, 11vw, 3rem);
    }

    .bottom-nav a i {
        font-size: clamp(0.95rem, 3.8vw, 1.2rem);
    }

    .top-user-name {
        display: none;
    }
    
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }

    .thai-address-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
}

/* Mobile First */
@media (max-width: 576px) {
    .app-layout {
        padding-bottom: 6.25rem;
    }

    .container {
        padding: 0 10px;
    }

    .nav-brand {
        font-size: 1.15rem;
    }

    .nav-brand span,
    .top-actions {
        font-size: 0.8rem;
    }

    .calendar-toolbar,
    .appointment-modal-header,
    .appointment-modal-body,
    .appointment-modal-footer {
        padding: 0.85rem;
    }

    .calendar-weekdays div {
        padding: 0.55rem 0.25rem;
        font-size: 0.86rem;
    }

    .calendar-day {
        min-height: 5.4rem;
        padding: 0.32rem;
    }

    .day-number {
        width: 1.45rem;
        height: 1.45rem;
        font-size: 0.86rem;
    }

    .appointment-chip {
        border-left-width: 2px;
    }

    .chip-title {
        max-width: 100%;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    .card-body,
    .card-header,
    .card-footer {
        padding: 1rem;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem;
    }
}

/* Animations */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slide-in-right {
    animation: slideInRight 0.5s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(30px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Loading Spinner */
.spinner {
    border: 4px solid var(--light);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Print Styles */
@media print {
    header, nav, .navbar, .toolbar, .bottom-bar, .pagination, .btn {
        display: none !important;
    }
    
    .main-content {
        padding: 0;
    }
    
    body {
        background-color: white;
    }
}
/* =========================================================
   Appointment Calendar Hover UX Hint - Stable Grid Version
   แก้ช่องวันที่แคบ + แก้ช่องตารางไม่ตรงกับหัวตาราง
   วางแทนชุด Appointment Calendar Hover UX Hint เดิมท้ายไฟล์
========================================================= */

/* ให้หัวตารางและช่องวันใช้ grid 7 ช่องเท่ากัน */
.calendar-weekdays,
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    width: 100%;
}

/* ห้ามใช้ align-items:start เพราะจะทำให้ช่องในแถวเดียวกันสูงไม่เท่ากัน */
.calendar-grid {
    position: relative;
    align-items: stretch;
    overflow: hidden;
    background: #ffffff;
}

/* ตัวครอบปฏิทินต้องไม่ปล่อยให้ hover ล้นจนตารางเพี้ยน */
.thai-calendar-shell,
.thai-calendar {
    overflow: hidden;
}

/* ช่องวันต้องกินพื้นที่เต็ม column */
.calendar-day {
    position: relative;
    z-index: 1;
    width: 100%;
    min-width: 0;
    min-height: 7.5rem;
    height: auto;
    overflow: hidden;
    transition:
        background 0.24s ease,
        box-shadow 0.24s ease,
        transform 0.24s ease,
        border-color 0.24s ease;
}

/* วันว่าง */
.calendar-day.is-empty {
    pointer-events: none;
}

/* hover แล้วเน้นช่อง แต่ไม่เปลี่ยน layout grid */
.calendar-day:not(.is-empty):hover,
.calendar-day:not(.is-empty):focus,
.calendar-day:not(.is-empty):focus-within {
    z-index: 10;
    background: #f1f8e9;
    border-color: rgba(76, 175, 80, 0.35);
    box-shadow: inset 0 0 0 1px rgba(76, 175, 80, 0.25);
    transform: none;
}

/* Premium theme */
.app-layout .calendar-day:not(.is-empty):hover,
.app-layout .calendar-day:not(.is-empty):focus,
.app-layout .calendar-day:not(.is-empty):focus-within {
    background:
        linear-gradient(135deg, rgba(241, 248, 233, 0.98), rgba(255, 255, 255, 0.98));
    border-color: rgba(76, 175, 80, 0.32);
}

/* รายการนัดหมาย: ไม่บีบเป็น 0 แล้ว เพื่อไม่ให้ช่องวันดูแคบ */
.appointment-stack {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
    max-height: 5.5rem;
    overflow-y: auto;
    flex: 1;
    opacity: 1;
    transform: none;
}

/* ถ้าวันไม่มีนัด ให้เหลือพื้นที่สำหรับ hint */
.calendar-day:not(.has-appointments) .appointment-stack {
    max-height: 0;
    overflow: hidden;
}

/* scrollbar */
.appointment-stack::-webkit-scrollbar {
    width: 4px;
}

.appointment-stack::-webkit-scrollbar-thumb {
    background: rgba(102, 112, 133, 0.35);
    border-radius: 999px;
}

.appointment-stack::-webkit-scrollbar-track {
    background: transparent;
}

/* chip นัดหมาย แสดงปกติ ไม่ซ่อน */
.appointment-chip {
    opacity: 1;
    transform: none;
    transition:
        background 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.2s ease;
}

.appointment-chip:hover,
.appointment-chip:focus {
    outline: none;
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.18);
    transform: translateX(2px);
}

/* ตัวเลขวันที่ */
.calendar-day:not(.is-empty):hover .day-number,
.calendar-day:not(.is-empty):focus .day-number,
.calendar-day:not(.is-empty):focus-within .day-number {
    background: rgba(76, 175, 80, 0.16);
    color: #1b5e20;
}

.calendar-day.is-today:hover .day-number,
.calendar-day.is-today:focus .day-number,
.calendar-day.is-today:focus-within .day-number {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #ffffff;
}

/* Hint สำหรับวันที่ยังไม่มีนัด */
.calendar-empty-hint {
    position: absolute;
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 2.15rem;
    padding: 0.35rem 0.5rem;
    border: 1px dashed rgba(76, 175, 80, 0.42);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.82);
    color: #2e7d32;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    opacity: 0;
    transform: translateY(0.3rem);
    pointer-events: none;
    transition:
        opacity 0.24s ease,
        transform 0.24s ease,
        background 0.24s ease;
}

.calendar-empty-hint i {
    font-size: 0.82rem;
}

/* แสดง hint เฉพาะวันที่ไม่มีนัด */
.calendar-day:not(.is-empty):not(.has-appointments):hover .calendar-empty-hint,
.calendar-day:not(.is-empty):not(.has-appointments):focus .calendar-empty-hint,
.calendar-day:not(.is-empty):not(.has-appointments):focus-within .calendar-empty-hint {
    opacity: 1;
    transform: translateY(0);
}

/* วันที่มี appointment ไม่ต้องแสดง hint */
.calendar-day.has-appointments .calendar-empty-hint {
    display: none;
}

/* แก้เส้นขอบขวาให้ตรงกับคอลัมน์จริง */
.calendar-day:nth-child(7n) {
    border-right: none;
}

/* มือถือ */
@media (max-width: 768px) {
    .calendar-weekdays,
    .calendar-grid {
        grid-template-columns: repeat(7, minmax(0, 1fr));
    }

    .calendar-day {
        min-height: 6.4rem;
        padding: 0.42rem;
    }

    .appointment-stack {
        max-height: 3.4rem;
    }

    .calendar-empty-hint {
        left: 0.3rem;
        right: 0.3rem;
        bottom: 0.3rem;
        min-height: 1.75rem;
        padding: 0.22rem 0.3rem;
        font-size: 0.66rem;
    }
}

@media (max-width: 576px) {
    .calendar-day {
        min-height: 5.6rem;
        padding: 0.32rem;
    }

    .appointment-chip {
        font-size: 0.72rem;
    }

    .calendar-empty-hint {
        font-size: 0.62rem;
    }

    .calendar-empty-hint i {
        display: none;
    }
}

/* =========================================================
   Appointment Calendar Event Position Fix
   แก้รายการนัดหมายอยู่กลางช่องวัน / เวลาไม่ชัด
   วางต่อท้าย public/css/style.css
========================================================= */

/* ให้ content ในช่องวันเริ่มจากด้านบน */
.calendar-day {
    justify-content: flex-start;
    align-items: stretch;
}

/* เลขวันที่อยู่บนสุด */
.day-number {
    flex: 0 0 auto;
}

/* รายการนัดหมายอยู่ใต้เลขวันที่ ไม่ยืดไปกลางช่อง */
.appointment-stack {
    flex: 0 0 auto;
    width: 100%;
    margin-top: 0.15rem;
    align-self: stretch;
    justify-content: flex-start;
}

/* วันที่มีนัดหมาย ให้แสดงรายการจากด้านบน */
.calendar-day.has-appointments .appointment-stack {
    max-height: 5.6rem;
    opacity: 1;
    transform: none;
    overflow-y: auto;
}

/* ปุ่มรายการนัดหมายไม่ให้เนื้อหาถูกจัดกลางเกินไป */
.appointment-chip {
    justify-content: flex-start;
    align-items: center;
    text-align: left;
}

/* เวลาในรายการให้มองเห็นชัด และไม่ถูกบีบ */
.chip-time {
    display: inline-flex;
    flex: 0 0 auto;
    min-width: 2.65rem;
    max-width: 2.65rem;
    align-items: center;
    justify-content: center;
    padding: 0.05rem 0.28rem;
    border-radius: 6px;
    background: rgba(13, 71, 161, 0.08);
    color: inherit;
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1.1;
    opacity: 1;
}

/* ชื่อรายการให้กินพื้นที่ที่เหลือ */
.chip-title {
    flex: 1 1 auto;
    min-width: 0;
}

/* มือถือเดิมเคยซ่อนเวลาไว้ ให้เปิดกลับมา */
@media (max-width: 768px) {
    .chip-time {
        display: inline-flex;
        min-width: 2.45rem;
        max-width: 2.45rem;
        font-size: 0.68rem;
        padding: 0.04rem 0.2rem;
    }

    .appointment-chip {
        gap: 0.22rem;
    }
}

@media (max-width: 420px) {
    .chip-time {
        min-width: 2.15rem;
        max-width: 2.15rem;
        font-size: 0.62rem;
    }

    .appointment-chip {
        font-size: 0.68rem;
    }
}

/* =========================================================
   Mobile Top Spacing Fix
   แก้ card / calendar / list หล่นลงล่างเกินไปบนมือถือ
   วางต่อท้าย public/css/style.css
========================================================= */

@media (max-width: 768px) {
    /* ลดช่องว่างบนของ content ใน Framework7 shell */
    .framework7-shell .page-content.main-content {
        padding-top: 0.75rem !important;
    }

    /* ถ้าใช้ app-layout ธรรมดา ให้ content ชิดบนขึ้น */
    .app-layout .main-content {
        padding-top: 0.75rem !important;
    }

    /* ลดระยะบนของ block หลัก */
    .app-page-block {
        padding-top: 0 !important;
    }

    /* ลดช่องว่างระหว่างหัวหน้าเพจกับ card */
    .app-page-head,
    .calendar-page-head {
        margin-bottom: 0.75rem !important;
    }

    /* ลด margin ของ calendar/card */
    .app-layout .card,
    .app-layout .thai-calendar-shell {
        margin-top: 0 !important;
        margin-bottom: 0.75rem !important;
    }

    /* ลด padding ใน toolbar ของ calendar */
    .calendar-toolbar {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }
}

@media (max-width: 576px) {
    .framework7-shell .page-content.main-content {
        padding-top: 0.5rem !important;
    }

    .app-layout .main-content {
        padding-top: 0.5rem !important;
    }

    .app-page-head,
    .calendar-page-head {
        margin-bottom: 0.6rem !important;
    }

    .calendar-toolbar {
        padding-top: 0.65rem !important;
        padding-bottom: 0.65rem !important;
    }
}
