@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;600;700&display=swap');

:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --accent: #f59e0b;
    --accent-2: #f97316;
    --field-border: #c2410c;
    --shadow: 0 18px 36px rgba(2, 6, 23, 0.08);
}

html[data-theme='dark'] {
    --bg: #0f172a;
    --panel: #3d3d3d;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --line: #1f2937;
    --accent: #fbbf24;
    --accent-2: #f97316;
    --field-border: #fdba74;
    --shadow: 0 16px 34px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: radial-gradient(1200px 600px at -10% -10%, rgba(245, 158, 11, 0.16), transparent 60%), var(--bg);
    color: var(--text);
    font-family: 'Poppins', sans-serif;
}

body.auth-screen {
    background-image: url('../images/login-bg.jpg');
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center center;
    background-attachment: fixed;
}

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

.app-shell {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: 260px;
    background: linear-gradient(165deg, #111827 0%, #1f2937 100%);
    color: #f3f4f6;
    padding: 20px 14px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
}

.brand img {
    width: 100%;
    border-radius: 12px;
}

.sidebar-tenant-brand {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 6px;
    display: grid;
    justify-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-tenant-brand img {
    width: 100%;
    max-height: 40px;
    object-fit: contain;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    padding: 3px;
}

.sidebar-tenant-brand strong {
    text-align: center;
    font-size: 0.78rem;
    color: #f8fafc;
    line-height: 1.15;
}

.sidebar nav {
    display: grid;
    gap: 8px;
}

.sidebar nav a {
    border-radius: 10px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #d1d5db;
}

.sidebar-sms-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: #ffffff;
    background: #ef4444;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.sidebar nav a.sms-inbox-alert {
    animation: smsInboxPulse 1.2s ease-in-out infinite;
}

@keyframes smsInboxPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55);
    }
    70% {
        box-shadow: 0 0 0 9px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.sidebar nav a.active,
.sidebar nav a:hover {
    background: rgba(245, 158, 11, 0.18);
    color: #ffffff;
}

.sidebar nav a.logout-pill,
.sidebar nav a.logout-pill:hover {
    background: #dc2626;
    color: #ffffff;
    border-radius: 999px;
    justify-content: center;
    font-weight: 600;
    margin-top: 6px;
}

.sidebar nav .disabled-link {
    opacity: 0.6;
    cursor: default;
}

.sidebar-user {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding-top: 14px;
    display: grid;
    gap: 2px;
}

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

.sidebar-user small {
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.7rem;
}

.sidebar-logout-icon {
    min-width: 30px;
    height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #dc2626;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 0.78rem;
    font-weight: 600;
}

.sidebar-logout-icon:hover {
    background: #ef4444;
    color: #ffffff;
}

.content {
    flex: 1;
    padding: 22px;
}

.with-sidebar {
    margin-left: 260px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.topbar-right {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar h1 {
    margin: 0;
    font-size: 1.25rem;
}

.icon-btn {
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    width: 42px;
    height: 42px;
    border-radius: 10px;
    cursor: pointer;
}

.mobile-menu-toggle {
    display: none;
}

.alert {
    border-radius: 10px;
    padding: 12px 14px;
    margin: 0 0 16px;
    border: 1px solid transparent;
}

.alert-error {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.2);
    color: #b91c1c;
}

.alert-success {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.2);
    color: #15803d;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.24);
    color: #b45309;
}

.alert-warning a {
    text-decoration: underline;
    margin-left: 8px;
}

.page-flow {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 0.92rem;
}

.page-flow a {
    color: #ffffff;
    text-decoration: none;
    background: var(--accent-2);
    border: 1px solid var(--accent-2);
    border-radius: 999px;
    padding: 6px 12px;
    font-weight: 600;
}

.page-flow .flow-sep {
    display: none;
}

.page-flow .current {
    color: var(--text);
    font-weight: 600;
    background: rgba(249, 115, 22, 0.16);
    border: 1px solid rgba(249, 115, 22, 0.4);
    border-radius: 999px;
    padding: 6px 12px;
}

.cards-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.stat-card h3 {
    margin: 0;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.88rem;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 1.9rem;
    line-height: 1.1;
}

.stat-card i {
    color: var(--accent-2);
    font-size: 1.5rem;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    margin-top: 20px;
    padding: 20px;
}

.panel h2 {
    margin-top: 0;
}

.panel label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.85rem;
}

.panel input,
.panel select,
.panel textarea {
    width: 100%;
    border: 1px solid var(--field-border);
    border-radius: 10px;
    padding: 10px;
    background: transparent;
    color: var(--text);
    margin-bottom: 10px;
}

.panel input[type='checkbox'] {
    width: auto;
    margin-bottom: 0;
}

.checkbox-row {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin: 8px 0 2px;
}

.panel h3 {
    margin-top: 10px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 10px;
    border-bottom: 1px solid var(--line);
    font-size: 0.92rem;
}

.row-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

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

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

.btn-secondary {
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
}

.btn-danger {
    border: 1px solid rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.08);
    color: #b91c1c;
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
}

.inline-form {
    display: inline;
}

@media (max-width: 900px) {
    .form-grid.two-col {
        grid-template-columns: 1fr;
    }
}

.sms-shell {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 14px;
    align-items: stretch;
}

.sms-left {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    max-height: 72vh;
    overflow: auto;
}

.sms-right {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    min-height: 72vh;
}

.sms-contact {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 8px;
}

.sms-contact.active {
    background: rgba(249, 115, 22, 0.12);
}

.sms-contact small {
    color: var(--muted);
}

.sms-unread {
    background: #ef4444;
    color: #fff;
    border-radius: 999px;
    font-size: 0.75rem;
    min-width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.sms-thread {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    flex: 1;
    overflow: auto;
    background: rgba(0, 0, 0, 0.04);
}

.sms-bubble {
    max-width: 78%;
    border-radius: 14px;
    padding: 10px;
    margin-bottom: 8px;
}

.sms-bubble p {
    margin: 0 0 6px;
}

.sms-bubble small {
    color: var(--muted);
}

.sms-bubble.inbound {
    background: var(--panel);
    border: 1px solid var(--line);
}

.sms-bubble.outbound {
    margin-left: auto;
    background: rgba(249, 115, 22, 0.2);
    border: 1px solid rgba(249, 115, 22, 0.45);
}

.sms-compose {
    margin-top: 10px;
    display: grid;
    gap: 10px;
}

.sms-messenger .sms-left {
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.55);
}

.sms-messenger .sms-right {
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
}

.sms-page-panel {
    margin-top: 8px;
    min-height: calc(100vh - 98px);
    padding: 12px;
}

.sms-page-panel.sms-shell {
    min-height: calc(100vh - 130px);
    height: calc(100vh - 98px);
}

.sms-page-panel .sms-left,
.sms-page-panel .sms-right {
    height: 100%;
}

.sms-page-panel .sms-left {
    max-height: none;
    display: flex;
    flex-direction: column;
}

.sms-page-panel .sms-right {
    min-height: 0;
}

.sms-messenger .sms-contact {
    border-radius: 14px;
    margin-bottom: 6px;
    align-items: center;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.sms-messenger .sms-contact:hover {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.35);
}

.sms-messenger .sms-contact.active {
    background: rgba(59, 130, 246, 0.16);
    border-color: rgba(59, 130, 246, 0.45);
}

.sms-contact-flash {
    animation: smsContactFlash 1.8s ease-in-out;
}

@keyframes smsContactFlash {
    0% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.85);
        border-color: rgba(245, 158, 11, 0.95);
        background: rgba(245, 158, 11, 0.22);
    }
    45% {
        box-shadow: 0 0 0 7px rgba(245, 158, 11, 0.05);
    }
    100% {
        box-shadow: none;
    }
}

.sms-contact-line {
    display: block;
    min-width: 0;
}

.sms-contact-line strong {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sms-contact-main {
    min-width: 0;
    flex: 1;
}

.sms-contact-meta {
    margin-top: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sms-contact-preview {
    color: var(--muted);
    font-size: 0.86rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.sms-contact-time {
    color: var(--muted);
    font-size: 0.82rem;
    white-space: nowrap;
    flex: 0 0 auto;
}

.sms-contact-phone {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sms-chat-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 8px;
}

.sms-chat-head h2 {
    margin: 0;
}

.sms-chat-head-phone {
    color: var(--muted);
    font-size: 0.95rem;
}

.sms-date-divider {
    text-align: center;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 600;
    margin: 14px 0 10px;
}

.sms-messenger .sms-thread {
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.95), rgba(241, 245, 249, 0.9));
    padding: 14px;
}

.sms-messenger .sms-bubble {
    position: relative;
    max-width: 72%;
    border-radius: 18px;
    padding: 10px 12px;
    margin-bottom: 10px;
    border: 0;
}

.sms-messenger .sms-bubble p {
    margin: 0 0 5px;
}

.sms-messenger .sms-bubble small {
    display: block;
    font-size: 0.78rem;
}

.sms-messenger .sms-bubble.inbound {
    background: #d9d9d9;
    color: #111827;
    border-bottom-left-radius: 6px;
}

.sms-messenger .sms-bubble.outbound {
    margin-left: auto;
    background: #fdaa77;
    color: #111827;
    border-bottom-right-radius: 6px;
}

.sms-messenger .sms-bubble.outbound small {
    color: rgba(17, 24, 39, 0.8);
}

.sms-media-wrap {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 6px 0 4px;
}

.sms-media-link {
    display: inline-block;
}

.sms-media-image {
    max-width: 180px;
    max-height: 180px;
    border-radius: 10px;
    border: 1px solid rgba(15, 23, 42, 0.18);
    object-fit: cover;
    display: block;
}

.sms-media-file {
    text-decoration: none;
}

.sms-compose textarea {
    font-family: 'Nunito Sans', 'Poppins', sans-serif;
}

.sms-compose-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.sms-compose-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.sms-attach-btn input[type='file'] {
    display: none;
}

.sms-emoji-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.9);
}

.sms-emoji-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    font-size: 1.1rem;
    line-height: 1;
    padding: 6px 8px;
    cursor: pointer;
}

.sms-file-list {
    margin: 0;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 600;
}

html[data-theme='dark'] .sms-page-panel {
    background: #1e293b;
    border-color: #334155;
}

html[data-theme='dark'] .sms-messenger .sms-left,
html[data-theme='dark'] .sms-messenger .sms-right {
    background: #0f172a;
    border-color: #334155;
}

html[data-theme='dark'] .sms-messenger .sms-left h2,
html[data-theme='dark'] .sms-messenger .sms-right h2,
html[data-theme='dark'] .sms-chat-head-phone,
html[data-theme='dark'] .sms-date-divider {
    color: #cbd5e1;
}

html[data-theme='dark'] .sms-messenger .sms-contact {
    background: #0b1220;
    border-color: #334155;
}

html[data-theme='dark'] .sms-messenger .sms-contact:hover {
    background: #13223a;
    border-color: #3b82f6;
}

html[data-theme='dark'] .sms-messenger .sms-contact.active {
    background: #1e293b;
    border-color: #60a5fa;
}

html[data-theme='dark'] .sms-contact-phone {
    color: #94a3b8;
}

html[data-theme='dark'] .sms-contact-preview,
html[data-theme='dark'] .sms-contact-time {
    color: #94a3b8;
}

html[data-theme='dark'] .sms-messenger .sms-thread {
    background: #111827;
    border-color: #334155;
}

html[data-theme='dark'] .sms-messenger .sms-bubble.inbound {
    background: #d9d9d9;
    color: #111827;
}

html[data-theme='dark'] .sms-messenger .sms-bubble.inbound small {
    color: #1f2937;
}

html[data-theme='dark'] .sms-messenger .sms-bubble.outbound {
    background: #fdaa77;
    color: #111827;
}

html[data-theme='dark'] .sms-messenger .sms-bubble.outbound small {
    color: #1f2937;
}

html[data-theme='dark'] .sms-compose textarea,
html[data-theme='dark'] .sms-compose .btn-secondary,
html[data-theme='dark'] .sms-emoji-panel {
    background: #0b1220;
    border-color: #334155;
    color: #e2e8f0;
}

.email-shell {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 14px;
    margin-top: 8px;
    min-height: calc(100vh - 98px);
    padding: 12px;
}

.email-left {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    overflow: auto;
    height: calc(100vh - 130px);
}

.email-right {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 130px);
    overflow: auto;
}

.email-contact {
    display: flex;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 8px;
}

.email-contact:hover {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.35);
}

.email-contact.active {
    background: rgba(59, 130, 246, 0.14);
    border-color: rgba(59, 130, 246, 0.45);
}

.email-contact-main {
    min-width: 0;
    flex: 1;
}

.email-contact-line {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.email-contact-line strong {
    display: block;
    width: 100%;
}

.email-contact-email {
    color: var(--muted);
    font-size: 0.86rem;
}

.email-contact-meta {
    margin-top: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.email-contact-preview {
    color: var(--muted);
    font-size: 0.84rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.email-contact-time {
    color: var(--muted);
    font-size: 0.8rem;
    white-space: nowrap;
}

.email-compose-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.email-compose-head h2 {
    margin: 0;
}

.email-compose-head span {
    color: var(--muted);
    font-size: 0.9rem;
}

.email-compose-form {
    display: grid;
    gap: 10px;
}

.email-cc-grid,
.email-sign-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.email-editor-wrap {
    border: 1px solid var(--field-border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--panel);
}

.email-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px;
    border-bottom: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.02);
}

.email-editor-toolbar select,
.email-editor-toolbar input[type='color'] {
    width: auto;
    margin-bottom: 0;
    padding: 6px 8px;
    border-radius: 8px;
}

.email-editor {
    min-height: 220px;
    padding: 12px;
    outline: none;
    overflow: auto;
}

.email-doc-selected {
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 600;
}

.email-recent-wrap {
    margin-top: 12px;
}

.email-recent-wrap h3 {
    margin: 0 0 8px;
}

.email-doc-modal {
    width: min(760px, 94vw);
}

.email-doc-list {
    border: 1px solid var(--line);
    border-radius: 10px;
    max-height: 48vh;
    overflow: auto;
}

.email-doc-row {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
}

.email-doc-row:last-child {
    border-bottom: 0;
}

.email-doc-name {
    font-weight: 600;
    word-break: break-word;
}

.signature-preview {
    max-width: 520px;
    max-height: 88px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.03);
}

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

.settings-hub-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    display: grid;
    gap: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.settings-hub-card:hover {
    transform: translateY(-2px);
    border-color: rgba(249, 115, 22, 0.45);
}

.settings-hub-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(249, 115, 22, 0.14);
    color: #f97316;
    font-size: 1rem;
}

.settings-hub-card strong {
    font-size: 1rem;
}

.settings-hub-card small {
    color: var(--muted);
    line-height: 1.35;
}

.reminder-grid {
    margin-top: 10px;
}

.reminder-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    background: var(--panel);
}

.reminder-card h3 {
    margin: 0 0 8px;
}

html[data-theme='dark'] .email-shell {
    background: #1e293b;
    border-color: #334155;
}

html[data-theme='dark'] .email-left,
html[data-theme='dark'] .email-right {
    background: #0f172a;
    border-color: #334155;
}

html[data-theme='dark'] .email-contact {
    background: #0b1220;
    border-color: #334155;
}

html[data-theme='dark'] .email-contact.active {
    background: #1e293b;
    border-color: #60a5fa;
}

html[data-theme='dark'] .email-contact-email,
html[data-theme='dark'] .email-contact-preview,
html[data-theme='dark'] .email-contact-time,
html[data-theme='dark'] .email-compose-head span,
html[data-theme='dark'] .email-doc-selected {
    color: #94a3b8;
}

html[data-theme='dark'] .email-editor-wrap,
html[data-theme='dark'] .email-doc-list,
html[data-theme='dark'] .signature-preview {
    border-color: #334155;
    background: #0b1220;
}

html[data-theme='dark'] .email-editor-toolbar {
    border-color: #334155;
    background: #111827;
}

html[data-theme='dark'] .settings-hub-card {
    background: #0b1220;
    border-color: #334155;
}

html[data-theme='dark'] .reminder-card {
    background: #0b1220;
    border-color: #334155;
}

html[data-theme='dark'] .settings-hub-card small {
    color: #94a3b8;
}

.storage-usage {
    margin: 8px 0 12px;
}

.usage-bar {
    width: 100%;
    background: rgba(0, 0, 0, 0.08);
    border: 1px solid var(--line);
    border-radius: 999px;
    height: 12px;
    overflow: hidden;
}

.usage-bar span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #f59e0b, #f97316);
}

.doc-search-wrap {
    margin: 0 0 8px;
}

.doc-search-input {
    width: min(520px, 100%);
}

.doc-search-empty {
    margin: 10px 0 0;
    color: var(--muted);
    font-weight: 600;
}

.doc-crumbs {
    margin: 10px 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.doc-crumbs a {
    text-decoration: none;
    color: var(--accent-2);
    font-weight: 600;
}

.doc-toolbar {
    display: flex;
    gap: 10px;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

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

.doc-view-toggle {
    display: inline-flex;
    gap: 8px;
}

.doc-view-toggle .btn-secondary.active {
    background: rgba(249, 115, 22, 0.2);
}

.dropzone {
    border: 2px dashed var(--field-border);
    border-radius: 14px;
    padding: 14px;
    display: grid;
    gap: 10px;
    justify-items: start;
}

.dropzone.dragging {
    background: rgba(249, 115, 22, 0.15);
}

.doc-bulk-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 10px;
}

.doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.doc-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px;
    display: grid;
    gap: 8px;
}

.doc-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.doc-icon {
    font-size: 2rem;
}

.doc-thumb {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--line);
    display: block;
}

.doc-name {
    font-weight: 600;
    word-break: break-word;
}

.doc-modal {
    margin-top: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    background: var(--panel);
    max-width: 420px;
    gap: 8px;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    margin: 0;
    max-width: none;
    border: 0;
    border-radius: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-card {
    width: min(460px, 92vw);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    display: grid;
    gap: 10px;
    box-shadow: 0 24px 48px rgba(0,0,0,0.25);
}

.modal-card h3 {
    margin: 0;
}

.modal-card label {
    margin-bottom: 0;
}

.modal-card input {
    margin-bottom: 0;
}

.modal-card input,
.modal-card select,
.modal-card textarea {
    width: 100%;
    border: 1px solid var(--field-border);
    border-radius: 10px;
    padding: 10px;
    background: transparent;
    color: var(--text);
}

.share-link-box {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px;
}

.share-link-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.share-link-row input {
    flex: 1;
}

.image-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 20px;
}

.image-lightbox img {
    max-width: 92vw;
    max-height: 82vh;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.image-lightbox p {
    margin-top: 10px;
    color: #fff;
    font-weight: 600;
}

.lightbox-close {
    position: absolute;
    top: 14px;
    right: 18px;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    color: #fff;
    background: rgba(0, 0, 0, 0.3);
    font-size: 1.4rem;
    cursor: pointer;
}

.logo-preview-wrap {
    margin: 10px 0 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.03);
    display: flex;
    justify-content: center;
}

.logo-preview-wrap img {
    max-width: 100%;
    max-height: 180px;
    object-fit: contain;
}

.brand-color-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-color-row input[type='color'] {
    flex: 1;
    margin-bottom: 0;
}

.brand-color-chip {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid var(--line);
    display: inline-block;
    flex: 0 0 auto;
}

.brand-color-value {
    min-width: 84px;
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 600;
    letter-spacing: 0.02em;
}

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

.patient-panel-head h2 {
    margin-bottom: 0;
}

.patient-create-card {
    width: min(980px, 94vw);
}

.patient-details-card {
    width: min(1180px, 96vw);
    max-height: calc(100vh - 48px);
    overflow: auto;
}

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

.patient-detail-item {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.02);
    display: grid;
    gap: 4px;
}

.patient-detail-item strong {
    font-size: 0.85rem;
    color: var(--muted);
}

.patient-detail-item span {
    font-weight: 600;
    word-break: break-word;
}

.appointments-legend {
    display: flex;
    gap: 16px;
    align-items: center;
    margin: 14px 0 10px;
    color: var(--muted);
    font-weight: 600;
}

.appointments-legend span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.appointments-legend i {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    display: inline-block;
}

.appointments-calendar {
    margin-top: 8px;
    border-radius: 16px;
    background: #06070a;
    padding: 2px;
}

.appointments-week-nav {
    margin-top: 12px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.appointments-week-nav strong {
    font-size: 1rem;
}

.appointments-grid-wrap {
    overflow: auto;
    border-radius: 14px;
}

.appointments-grid {
    width: 100%;
    border-collapse: separate;
    border-spacing: 4px;
    min-width: 1220px;
}

.appointments-grid thead th {
    background: linear-gradient(180deg, #ff8a00 0%, #d97706 100%);
    color: #fff;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 700;
    padding: 9px 8px;
    text-align: center;
    white-space: nowrap;
}

.appointments-grid thead .time-col {
    min-width: 110px;
}

.appointments-grid .time-slot {
    background: linear-gradient(180deg, #f59e0b 0%, #b45309 100%);
    color: #fff;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.1;
    font-weight: 700;
    min-width: 110px;
    white-space: nowrap;
    text-align: left;
    vertical-align: top;
    padding: 9px 10px;
}

.appointments-grid td {
    vertical-align: top;
}

.appointments-grid .slot-card {
    min-height: 72px;
    border-radius: 14px;
    background: rgba(24, 26, 31, 0.98);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
    padding: 8px 9px;
    display: grid;
    align-content: flex-start;
    gap: 4px;
}

.appointments-grid .slot-line {
    font-size: 0.95rem;
    line-height: 1.18;
    font-weight: 700;
    word-break: break-word;
}

.appointments-grid .slot-confirmed {
    color: #00ff99;
}

.appointments-grid .slot-pending {
    color: #ffb020;
}

.appointments-grid .slot-other {
    color: #e2e8f0;
}

@media (max-width: 1280px) {
    .appointments-grid {
        min-width: 980px;
    }

    .appointments-grid thead th {
        font-size: 1rem;
    }

    .appointments-grid .time-slot {
        font-size: 1rem;
        min-width: 90px;
        padding: 10px 8px;
    }

    .appointments-grid .slot-card {
        min-height: 64px;
        padding: 7px;
        gap: 4px;
    }

    .appointments-grid .slot-line {
        font-size: 0.88rem;
    }
}

.tenant-settings-btn {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.business-hours-grid {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px;
    display: grid;
    gap: 8px;
}

.hours-row {
    display: grid;
    grid-template-columns: 130px 100px 1fr 1fr;
    gap: 8px;
    align-items: center;
}

.hours-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.footer {
    margin-top: 28px;
    color: var(--muted);
    text-align: center;
}

.auth-page {
    margin: 0 auto;
    width: 100%;
    max-width: 1180px;
}

.auth-layout {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 120px);
}

.auth-card {
    width: min(1080px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    overflow: hidden;
}

.auth-card-small {
    max-width: 520px;
    grid-template-columns: 1fr;
}

.auth-brand {
    padding: 36px;
    background: linear-gradient(135deg, #111827 0%, #27272a 50%, #3f3f46 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-brand img {
    width: min(98%, 620px);
    height: auto;
}

.auth-form {
    padding: 34px;
    display: grid;
    gap: 12px;
}

.auth-form h2 {
    margin: 0;
}

.auth-form p {
    color: var(--muted);
    margin: 0 0 8px;
}

.auth-form input {
    border: 1px solid var(--field-border);
    border-radius: 10px;
    padding: 12px;
    background: transparent;
    color: var(--text);
}

input,
select,
textarea {
    border-color: var(--field-border);
}

.btn-primary {
    border: 0;
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    color: #111827;
    font-weight: 700;
    background: linear-gradient(120deg, var(--accent), var(--accent-2));
}

.text-link {
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
}

.turnstile-wrap {
    margin: 4px 0 2px;
}

.auth-theme-toggle {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 120;
}

.auth-content .alert {
    max-width: 1080px;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 14px;
}

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

@media (max-width: 860px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .with-sidebar {
        margin-left: 0;
    }

    .mobile-menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .auth-card {
        grid-template-columns: 1fr;
    }

    .auth-brand {
        padding: 24px;
    }

    .auth-brand img {
        width: min(96%, 500px);
    }

    .sms-shell {
        grid-template-columns: 1fr;
    }

    .sms-left {
        max-height: 40vh;
    }

    .sms-page-panel.sms-shell {
        height: auto;
    }

    .sms-page-panel .sms-left,
    .sms-page-panel .sms-right {
        height: auto;
    }

    .email-shell {
        grid-template-columns: 1fr;
        min-height: auto;
        height: auto;
    }

    .email-left,
    .email-right {
        height: auto;
    }

    .email-left {
        max-height: 42vh;
    }

    .settings-hub-grid {
        grid-template-columns: 1fr;
    }

    .hours-row {
        grid-template-columns: 1fr 1fr;
    }

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

@media (max-width: 640px) {
    .content {
        padding: 14px;
    }

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

    .stat-card strong {
        font-size: 1.55rem;
    }
}
