/* Shared Light, Dark, and System theme layer. */
:root {
    color-scheme: light;
    --theme-transition-x: 50%;
    --theme-transition-y: 50%;
    --theme-bg: #f4f7fb;
    --theme-surface: #ffffff;
    --theme-surface-soft: #f7f9fc;
    --theme-text: #232a36;
    --theme-muted: #6e7a8a;
    --theme-border: #e5e7eb;
    --theme-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 450ms;
    animation-timing-function: ease-in-out;
}

::view-transition-old(root) {
    animation-name: theme-transition-out;
}

::view-transition-new(root) {
    animation-name: theme-transition-in;
    clip-path: circle(0 at var(--theme-transition-x) var(--theme-transition-y));
}

@keyframes theme-transition-out {
    to { opacity: 0.92; }
}

@keyframes theme-transition-in {
    to { clip-path: circle(150vmax at var(--theme-transition-x) var(--theme-transition-y)); }
}

html.theme-transitioning {
    animation: theme-transition-fallback 450ms ease-in-out;
}

@keyframes theme-transition-fallback {
    0% { opacity: 0.82; }
    100% { opacity: 1; }
}

.theme-toggle.is-switching i {
    animation: theme-toggle-spin 450ms ease-in-out;
}

@keyframes theme-toggle-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

html[data-theme="dark"] {
    color-scheme: dark;
    --theme-bg: #0b1220;
    --theme-surface: #111b2d;
    --theme-surface-soft: #172338;
    --theme-text: #e8eef8;
    --theme-muted: #a3b0c2;
    --theme-border: rgba(148, 163, 184, 0.22);
    --theme-shadow: 0 18px 55px rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: dark) {
    html[data-theme="system"] {
        color-scheme: dark;
        --theme-bg: #0b1220;
        --theme-surface: #111b2d;
        --theme-surface-soft: #172338;
        --theme-text: #e8eef8;
        --theme-muted: #a3b0c2;
        --theme-border: rgba(148, 163, 184, 0.22);
        --theme-shadow: 0 18px 55px rgba(0, 0, 0, 0.3);
    }
}

html[data-theme="light"],
html[data-theme="system"] {
    color-scheme: light;
}

html[data-theme="dark"] body,
html[data-theme="system"] body {
    background-color: var(--theme-bg);
    color: var(--theme-text);
}

body::before,
body::after {
    content: '';
    position: fixed;
    inset: -35%;
    pointer-events: none;
    z-index: 0;
    background-repeat: repeat;
    transform: rotate(-8deg);
}

body::before {
    background-image:
        repeating-linear-gradient(90deg, transparent 0 88px, rgba(20, 184, 166, 0.075) 88px 89px, transparent 89px 176px),
        repeating-linear-gradient(0deg, transparent 0 56px, rgba(59, 130, 246, 0.06) 56px 57px, transparent 57px 112px);
    background-size: 176px 112px;
    animation: tech-lines-drift 32s linear infinite;
}

body::after {
    background-image:
        linear-gradient(90deg, transparent 0 48%, rgba(20, 184, 166, 0.12) 49%, transparent 50%),
        linear-gradient(0deg, transparent 0 48%, rgba(59, 130, 246, 0.1) 49%, transparent 50%);
    background-size: 320px 224px;
    opacity: 0.42;
    animation: tech-lines-pulse 8s ease-in-out infinite alternate;
}

@keyframes tech-lines-drift {
    from { background-position: 0 0, 0 0; }
    to { background-position: 176px 112px, -112px 56px; }
}

@keyframes tech-lines-pulse {
    from { opacity: 0.22; transform: rotate(-8deg) translate3d(0, 0, 0); }
    to { opacity: 0.52; transform: rotate(-8deg) translate3d(18px, -12px, 0); }
}

body > * {
    position: relative;
    z-index: 1;
}

body > .theme-control {
    z-index: 1000;
}

.misetric-tooltip {
    position: fixed;
    z-index: 3000;
    max-width: min(240px, calc(100vw - 16px));
    padding: 8px 10px;
    border-radius: 7px;
    background: #111827;
    color: #fff;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.2);
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transform: translateY(3px);
    transition: opacity 140ms ease, transform 140ms ease;
}

.misetric-tooltip::after {
    content: '';
    position: absolute;
    left: 50%;
    top: -5px;
    width: 10px;
    height: 10px;
    background: #111827;
    transform: translateX(-50%) rotate(45deg);
}

.misetric-tooltip.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.misetric-page-loader {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    background: rgba(6, 18, 32, 0.96);
    opacity: 1;
    visibility: visible;
    transition: opacity 260ms ease, visibility 260ms ease;
}

.misetric-page-loader.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.misetric-loader-inner {
    position: relative;
    width: min(118px, 30vw);
    aspect-ratio: 1;
    display: grid;
    place-items: center;
}

.misetric-loader-mark {
    position: relative;
    z-index: 1;
    width: 68%;
    height: 68%;
    object-fit: contain;
    filter: brightness(0) invert(1) drop-shadow(0 0 18px rgba(94, 234, 212, 0.34));
    opacity: 0.94;
    animation: misetric-loader-breathe 1.8s ease-in-out infinite;
}

.misetric-loader-ring {
    position: absolute;
    inset: 0;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #5eead4;
    border-right-color: #60a5fa;
    border-radius: 50%;
    animation: misetric-loader-spin 800ms linear infinite;
}

@keyframes misetric-loader-spin {
    to { transform: rotate(360deg); }
}

@keyframes misetric-loader-breathe {
    0%, 100% { transform: scale(0.96); opacity: 0.72; }
    50% { transform: scale(1); opacity: 1; }
}

.is-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.82;
}

.misetric-button-spinner {
    display: inline-block;
    width: 0.9em;
    height: 0.9em;
    margin-right: 0.45em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    vertical-align: -0.12em;
    animation: misetric-loader-spin 700ms linear infinite;
}

@media (prefers-reduced-motion: reduce) {
    ::view-transition-old(root),
    ::view-transition-new(root),
    .misetric-loader-mark,
    .misetric-button-spinner,
    .theme-toggle.is-switching i {
        animation: none;
    }

    html.theme-transitioning {
        animation: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    body::before,
    body::after {
        animation: none;
    }
}

@media (prefers-color-scheme: dark) {
    html[data-theme="system"] body::before {
        background-image:
            repeating-linear-gradient(90deg, transparent 0 88px, rgba(94, 234, 212, 0.11) 88px 89px, transparent 89px 176px),
            repeating-linear-gradient(0deg, transparent 0 56px, rgba(96, 165, 250, 0.09) 56px 57px, transparent 57px 112px);
    }
}

html[data-theme="dark"] body::before {
    background-image:
        repeating-linear-gradient(90deg, transparent 0 88px, rgba(94, 234, 212, 0.11) 88px 89px, transparent 89px 176px),
        repeating-linear-gradient(0deg, transparent 0 56px, rgba(96, 165, 250, 0.09) 56px 57px, transparent 57px 112px);
}

html[data-theme="dark"] .theme-control,
html[data-theme="system"] .theme-control {
    color: var(--theme-text);
    background: var(--theme-surface);
    border-color: var(--theme-border);
}

/* Public landing pages */
html[data-theme="light"] body,
html[data-theme="system"] body {
    --bg: var(--theme-bg);
    --bg-soft: var(--theme-surface-soft);
    --panel: rgba(255, 255, 255, 0.86);
    --panel-light: rgba(255, 255, 255, 0.96);
    --text: var(--theme-text);
    --text-soft: var(--theme-muted);
    --muted: var(--theme-muted);
    --line: var(--theme-border);
    --white: #172033;
    --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
    background: linear-gradient(145deg, #f8fbff 0%, #edf7f6 100%);
}

html[data-theme="light"] .site-header,
html[data-theme="system"] .site-header,
html[data-theme="light"] .signup-panel,
html[data-theme="system"] .signup-panel,
html[data-theme="light"] .feature-item,
html[data-theme="system"] .feature-item,
html[data-theme="light"] .dashboard-frame,
html[data-theme="system"] .dashboard-frame {
    background: var(--theme-surface);
    color: var(--theme-text);
}

html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea,
html[data-theme="system"] input,
html[data-theme="system"] select,
html[data-theme="system"] textarea {
    background: var(--theme-surface);
    color: var(--theme-text);
    border-color: var(--theme-border);
}

html[data-theme="light"] .metric-card,
html[data-theme="light"] .chart-card,
html[data-theme="light"] .activity-card,
html[data-theme="light"] .business-card,
html[data-theme="light"] .preview-card,
html[data-theme="system"] .metric-card,
html[data-theme="system"] .chart-card,
html[data-theme="system"] .activity-card,
html[data-theme="system"] .business-card,
html[data-theme="system"] .preview-card {
    background: var(--theme-surface);
    color: var(--theme-text);
    border-color: var(--theme-border);
}

html[data-theme="light"] .btn-secondary,
html[data-theme="system"] .btn-secondary {
    color: var(--theme-text);
}

html[data-theme="light"] .business-card:hover,
html[data-theme="light"] .business-card.active,
html[data-theme="system"] .business-card:hover,
html[data-theme="system"] .business-card.active,
html[data-theme="dark"] .business-card:hover,
html[data-theme="dark"] .business-card.active {
    border-color: #0f8b83;
    background: linear-gradient(145deg, #f0fdfa, #e6fffb);
    color: #123b45;
    box-shadow: 0 10px 24px rgba(15, 139, 131, 0.18), inset 0 0 0 2px rgba(15, 139, 131, 0.18);
}

html[data-theme="light"] .business-card.active::after,
html[data-theme="system"] .business-card.active::after,
html[data-theme="dark"] .business-card.active::after {
    content: '\2713';
    position: absolute;
    top: 12px;
    right: 12px;
    display: grid;
    width: 24px;
    height: 24px;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: #0f8b83;
    font-size: 0.8rem;
    font-weight: 900;
    box-shadow: 0 4px 10px rgba(15, 139, 131, 0.24);
}

html[data-theme="light"] .business-card.active .business-icon,
html[data-theme="system"] .business-card.active .business-icon,
html[data-theme="dark"] .business-card.active .business-icon {
    color: #0f766e;
    background: rgba(20, 184, 166, 0.2);
}

html[data-theme="light"] .site-header,
html[data-theme="light"] .signup-panel,
html[data-theme="light"] .feature-item,
html[data-theme="light"] .dashboard-frame,
html[data-theme="light"] .business-card,
html[data-theme="light"] .preview-card,
html[data-theme="system"] .site-header,
html[data-theme="system"] .signup-panel,
html[data-theme="system"] .feature-item,
html[data-theme="system"] .dashboard-frame,
html[data-theme="system"] .business-card,
html[data-theme="system"] .preview-card {
    box-shadow: var(--theme-shadow);
}

html[data-theme="light"] .eyebrow,
html[data-theme="light"] .mini-label,
html[data-theme="system"] .eyebrow,
html[data-theme="system"] .mini-label {
    color: #0f766e;
    background: rgba(20, 184, 166, 0.1);
    border-color: rgba(13, 148, 136, 0.25);
}

html[data-theme="light"] .step-pill,
html[data-theme="system"] .step-pill {
    color: #1d4ed8;
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.24);
}

@media (prefers-color-scheme: dark) {
    html[data-theme="system"] body {
        --white: #ffffff;
        --shadow: 0 30px 80px rgba(15, 23, 42, 0.42);
        background: linear-gradient(150deg, #071421 0%, #0c1d2d 42%, #0b1623 100%);
    }

    html[data-theme="system"] .metric-card,
    html[data-theme="system"] .chart-card,
    html[data-theme="system"] .activity-card,
    html[data-theme="system"] .business-card,
    html[data-theme="system"] .preview-card {
        background: rgba(20, 36, 51, 0.8);
    }

    html[data-theme="system"] .eyebrow,
    html[data-theme="system"] .mini-label {
        color: #d8f9ff;
        background: rgba(94, 234, 212, 0.12);
        border-color: rgba(94, 234, 212, 0.2);
    }

    html[data-theme="system"] .step-pill {
        color: #dbeafe;
        background: rgba(96, 165, 250, 0.15);
        border-color: rgba(96, 165, 250, 0.2);
    }
}

/* Hotel application */
html[data-theme="dark"] body,
html[data-theme="system"] body {
    --bg: var(--theme-bg);
    --surface: var(--theme-surface);
    --surface-strong: var(--theme-surface-soft);
    --text: var(--theme-text);
    --muted: var(--theme-muted);
    --border: var(--theme-border);
    --shadow: var(--theme-shadow);
}

html[data-theme="dark"] .app-header,
html[data-theme="system"] .app-header,
html[data-theme="dark"] .card,
html[data-theme="system"] .card,
html[data-theme="dark"] .panel,
html[data-theme="system"] .panel,
html[data-theme="dark"] .auth-card,
html[data-theme="system"] .auth-card,
html[data-theme="dark"] .modal-content,
html[data-theme="system"] .modal-content {
    background: var(--theme-surface);
    color: var(--theme-text);
    border-color: var(--theme-border);
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="system"] input,
html[data-theme="system"] select,
html[data-theme="system"] textarea {
    background: var(--theme-surface-soft);
    color: var(--theme-text);
    border-color: var(--theme-border);
}

html[data-theme="dark"] .app-sidebar,
html[data-theme="system"] .app-sidebar {
    background: #080f1c;
}

/* Standalone restaurant and supermarket dashboards */
html[data-theme="dark"] .app-header,
html[data-theme="system"] .app-header,
html[data-theme="dark"] .app-sidebar,
html[data-theme="system"] .app-sidebar {
    border-color: var(--theme-border);
}

html[data-theme="dark"] .app-header,
html[data-theme="system"] .app-header,
html[data-theme="dark"] .card,
html[data-theme="system"] .card,
html[data-theme="dark"] .panel,
html[data-theme="system"] .panel,
html[data-theme="dark"] .mini-box,
html[data-theme="system"] .mini-box {
    background: var(--theme-surface);
    color: var(--theme-text);
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="system"] input,
html[data-theme="system"] select {
    background: var(--theme-surface-soft);
    color: var(--theme-text);
    border-color: var(--theme-border);
}

html[data-theme="dark"] .button-logout,
html[data-theme="system"] .button-logout {
    background: #e8eef8;
    color: #0b1220;
}

@media (prefers-color-scheme: dark) {
    html[data-theme="system"] .login-shell {
        background: var(--theme-surface);
        border-color: var(--theme-border);
    }

    html[data-theme="system"] .login-form,
    html[data-theme="system"] .login-form h2 {
        color: var(--theme-text);
    }

    html[data-theme="system"] .login-form input {
        background: var(--theme-surface-soft);
        color: var(--theme-text);
        border-color: var(--theme-border);
    }
}

html[data-theme="dark"] .login-shell {
    background: var(--theme-surface);
    border-color: var(--theme-border);
}

html[data-theme="dark"] .login-form,
html[data-theme="dark"] .login-form h2 {
    color: var(--theme-text);
}

html[data-theme="dark"] .login-form input {
    background: var(--theme-surface-soft);
    color: var(--theme-text);
    border-color: var(--theme-border);
}

.hotel-login-page {
    --hotel-ink: #172033;
    --hotel-muted: #697386;
    --hotel-brand: #0f8b83;
    --hotel-wash: #ecfdfa;
    --hotel-line: #d8e8e5;
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    color: var(--hotel-ink);
    background: radial-gradient(circle at 10% 10%, #d6f7ef, transparent 34%), linear-gradient(135deg, #f7fffd, #edf5f4);
    font-family: Inter, sans-serif;
}

.hotel-login-shell {
    width: min(960px, 100%);
    display: grid;
    grid-template-columns: 0.9fr 1.1fr;
    overflow: hidden;
    border: 1px solid var(--hotel-line);
    border-radius: 28px;
    background: #fff;
    box-shadow: var(--theme-shadow);
}

.hotel-login-aside {
    padding: 42px;
    color: #fff;
    background: linear-gradient(145deg, #075e5a, #0f8b83 62%, #53c7b4);
}

.hotel-login-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 800;
}

.hotel-login-logo i { font-size: 1.6rem; }

.hotel-login-aside h1 {
    margin: 90px 0 16px;
    font-size: clamp(2rem, 5vw, 3.5rem);
    line-height: 1;
}

.hotel-login-aside p {
    color: #e4fffa;
    line-height: 1.7;
}

.hotel-login-form {
    padding: 42px;
}

.hotel-login-form h2 {
    margin: 0 0 8px;
    color: var(--hotel-ink);
    font-size: 2rem;

    color: var(--hotel-muted);
}

.hotel-login-error {
    margin-bottom: 18px;
    padding: 12px 14px;
    border: 1px solid #fecaca;
    border-radius: 10px;
    color: #9b1c1c;
    background: #fff0f0;
}

.hotel-login-form label {
    display: grid;
    gap: 8px;
    margin-top: 16px;
    color: var(--hotel-muted);
    font-size: 0.9rem;
    font-weight: 700;
}

.hotel-login-form input {
    width: 100%;
    padding: 14px 15px;
    border: 1px solid var(--hotel-line);
    border-radius: 11px;
    color: var(--hotel-ink);
    background: #fafffe;
    outline: none;
}

.hotel-login-form input:focus {
    border-color: var(--hotel-brand);
    box-shadow: 0 0 0 4px rgba(15, 139, 131, 0.12);
}

.hotel-login-form button,
.hotel-login-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 26px;
    padding: 14px 18px;
    border: 0;
    border-radius: 11px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.hotel-login-form button {
    width: 100%;
    color: #fff;
    background: var(--hotel-brand);
}

.hotel-login-back {
    color: var(--hotel-ink);
    background: var(--hotel-wash);
    text-decoration: none;
}

html[data-theme="dark"] .hotel-login-shell,
html[data-theme="system"] .hotel-login-shell {
    background: var(--theme-surface);
    border-color: var(--theme-border);
}

html[data-theme="dark"] .hotel-login-form h2,
html[data-theme="dark"] .hotel-login-back,
html[data-theme="system"] .hotel-login-form h2,
html[data-theme="system"] .hotel-login-back {
    color: var(--theme-text);
}

html[data-theme="dark"] .hotel-login-form input,
html[data-theme="system"] .hotel-login-form input {
    color: var(--theme-text);
    background: var(--theme-surface-soft);
    border-color: var(--theme-border);
}

@media (prefers-color-scheme: dark) {
    html[data-theme="system"] .hotel-login-page {
        background: radial-gradient(circle at 90% 10%, #123c42, transparent 34%), linear-gradient(135deg, #0b1720, #101d2b);
    }
}

@media (max-width: 720px) {
    .hotel-login-shell { grid-template-columns: 1fr; }
    .hotel-login-aside { padding: 28px; }
    .hotel-login-aside h1 { margin-top: 54px; }
    .hotel-login-form { padding: 30px 24px; }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.required-feedback {
    display: block;
    min-height: 1em;
    margin-top: 5px;
    color: #dc2626;
    font: 600 0.76rem/1.3 Inter, sans-serif;
}

input.has-required-error,
select.has-required-error,
textarea.has-required-error {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1) !important;
}

html[data-theme="dark"] .required-feedback,
html[data-theme="system"] .required-feedback {
    color: #fda4af;
}

.theme-control {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1000;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 12px;
    color: #172033;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
    backdrop-filter: blur(12px);
    font: 600 12px/1.2 Inter, sans-serif;
}

.theme-control label { margin: 0; }
.theme-control select { width: auto; min-width: 86px; padding: 5px 24px 5px 7px; border-radius: 8px; font-size: 12px; }
.theme-control select:focus { transform: none; }

@media (max-width: 640px) {
    .theme-control { right: 12px; bottom: 12px; }
    .theme-control span { display: none; }
}

html[data-theme="dark"] .business-card:hover,
html[data-theme="dark"] .business-card.active,
html[data-theme="dark"] .business-card.active:hover {
    border-color: #0f8b83 !important;
    background: linear-gradient(145deg, #123b45, #0f2935) !important;
    color: #e6fffb !important;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24), inset 0 0 0 2px rgba(20, 184, 166, 0.22) !important;
}

html[data-theme="dark"] .business-card.active::after {
    content: '\2713' !important;
    background: #0f8b83 !important;
    color: #fff !important;
}

html[data-theme="dark"] .business-card.active .business-icon {
    color: #99f6e4 !important;
    background: rgba(20, 184, 166, 0.18) !important;
}
