/* Custom variables matching layouts.auth-card */
:root {
    --ink: #1f2428;
    --muted: #5a626b;
    --line: #d9dee3;
    --brand: #175296;
    --brand-dark: #103b70;
    --bg: #f4f6f7;
    --white: #fff;
}

/* Filled primary actions throughout the dashboard. */
.fi-btn.fi-color-primary:not(.fi-outlined) {
    --bg: var(--brand) !important;
    --hover-bg: var(--brand-dark) !important;
    --text: var(--white) !important;
    --hover-text: var(--white) !important;
    background-color: var(--brand) !important;
    color: var(--white) !important;
    transition: background-color .2s ease, color .2s ease !important;
}

.fi-btn.fi-color-primary:not(.fi-outlined):hover {
    background-color: var(--brand-dark) !important;
    color: var(--white) !important;
}

.fi-btn.fi-color-primary:not(.fi-outlined) .fi-icon {
    color: currentColor !important;
}

.max-outstanding-amount {
    color: #b42318;
    font-size: 1.2rem;
}

.max-completion-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.max-completion-summary span {
    display: grid;
    gap: 4px;
    border: 1px solid #d9e1ea;
    border-radius: 10px;
    padding: 12px;
    background: #f8fafc;
}

.max-completion-summary strong {
    color: var(--ink);
    font-size: 1.05rem;
}

.max-signature-pad {
    display: grid;
    gap: 12px;
    width: 100%;
}

.max-signature-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.max-signature-canvas-frame {
    position: relative;
    overflow: hidden;
    min-height: 300px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}

.max-signature-canvas {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: 300px;
    background: transparent;
    cursor: crosshair;
    touch-action: none;
}

.max-signature-canvas:focus-visible {
    outline: 4px solid rgba(23, 82, 150, .2);
    outline-offset: -6px;
}

.max-signature-button {
    min-height: 42px;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    padding: 0 16px;
    background: #fff;
    color: #263445;
    font-size: 14px;
    font-weight: 750;
    cursor: pointer;
}

.max-signature-button:hover {
    border-color: #175296;
    background: #eef5fc;
    color: #175296;
}

.max-signature-fullscreen-button {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 3;
    display: grid;
    width: 40px;
    min-height: 40px;
    padding: 0;
    border-color: #d1d5db;
    place-items: center;
    color: #4b5563;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

.max-signature-fullscreen-button svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.max-signature-done-button {
    border-color: #175296;
    background: #175296;
    color: #fff;
}

.max-signature-done-button:hover {
    background: #103b70;
    color: #fff;
}

.max-signature-pad.is-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 10000;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 14px;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    background: #f4f7fa;
}

.max-signature-pad.is-fullscreen .max-signature-canvas-frame {
    min-height: 0;
    border-width: 1px;
    border-radius: 8px;
}

.max-signature-pad.is-fullscreen .max-signature-canvas {
    height: 100%;
}

.max-signature-pad.is-fullscreen .max-signature-actions {
    justify-content: flex-end;
}

@media (max-width: 760px) {
    .max-completion-summary {
        grid-template-columns: 1fr 1fr;
    }

    .max-signature-canvas-frame {
        min-height: 260px;
    }

    .max-signature-canvas {
        height: 260px;
    }

    .max-signature-pad.is-fullscreen .max-signature-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .max-signature-pad.is-fullscreen .max-signature-button {
        width: 100%;
        min-height: 48px;
        font-size: 15px;
    }
}

/* Admin e-mail preview page. */
.email-preview-page {
    width: min(100%, 1120px);
    margin: 0 auto;
}

.email-preview-toolbar,
.email-preview-stage {
    border: 1px solid #d9e1ea;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(31, 36, 40, .06);
}

.email-preview-toolbar {
    display: flex;
    justify-content: center;
    padding: 22px 24px;
}

.email-preview-select {
    display: grid;
    width: min(100%, 420px);
    gap: 7px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
}

.email-preview-select select {
    width: 100%;
    min-height: 44px;
    border: 1px solid #b8c5d3;
    border-radius: 9px;
    padding: 0 38px 0 12px;
    background: #fff;
    color: var(--ink);
    font-size: 15px;
}

.email-preview-select select:focus {
    border-color: var(--brand);
    outline: 3px solid rgba(23, 82, 150, .16);
}

.email-preview-stage {
    margin-top: 22px;
    padding: 24px;
}

.email-preview-browser {
    overflow: hidden;
    border: 1px solid #cfd9e4;
    border-radius: 12px;
    background: #eef3f8;
}

.email-preview-browser iframe {
    display: block;
    width: 100%;
    min-height: 780px;
    border: 0;
    background: #eef3f8;
}

@media (max-width: 760px) {
    .email-preview-stage,
    .email-preview-toolbar {
        padding: 18px;
    }

    .email-preview-browser iframe {
        min-height: 680px;
    }
}

/* Planning calendar. */
.planning-calendar {
    width: 100%;
}

.planning-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
    padding: 16px 18px;
    border: 1px solid #d9e1ea;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(31, 36, 40, .05);
}

.planning-period {
    display: flex;
    align-items: center;
    gap: 8px;
}

.planning-period button,
.planning-view-switch button {
    min-height: 38px;
    border: 1px solid #c8d3df;
    border-radius: 8px;
    padding: 0 13px;
    background: #fff;
    color: var(--ink);
    font-weight: 750;
    cursor: pointer;
}

.planning-period button:first-child,
.planning-period button:nth-child(3) {
    width: 38px;
    padding: 0;
    color: var(--brand);
    font-size: 24px;
    line-height: 1;
}

.planning-period button:hover,
.planning-view-switch button:hover {
    border-color: var(--brand);
    background: #eef5fc;
    color: var(--brand);
}

.planning-period h2 {
    margin: 0 0 0 10px;
    color: var(--ink);
    font-size: 20px;
    font-weight: 850;
}

.planning-view-switch {
    display: inline-flex;
    padding: 3px;
    border-radius: 10px;
    background: #edf2f7;
}

.planning-view-switch button {
    border: 0;
    background: transparent;
}

.planning-view-switch button.is-active {
    background: var(--brand);
    color: #fff;
    box-shadow: 0 2px 8px rgba(23, 82, 150, .2);
}

.planning-grid-wrap {
    overflow-x: auto;
    border: 1px solid #d9e1ea;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(31, 36, 40, .05);
}

.planning-weekdays,
.planning-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(140px, 1fr));
    min-width: 980px;
}

.planning-weekdays {
    border-bottom: 1px solid #d9e1ea;
    background: #f7f9fb;
}

.planning-weekdays div {
    padding: 11px 12px;
    color: #64748b;
    font-size: 12px;
    font-weight: 850;
    letter-spacing: .05em;
    text-align: center;
    text-transform: uppercase;
}

.planning-day {
    min-height: 150px;
    padding: 10px;
    border-right: 1px solid #e3e9ef;
    border-bottom: 1px solid #e3e9ef;
    background: #fff;
}

.planning-grid.is-week .planning-day {
    min-height: 520px;
}

.planning-day:nth-child(7n) {
    border-right: 0;
}

.planning-day.is-outside {
    background: #f8fafc;
}

.planning-day.is-outside > header,
.planning-day.is-outside .planning-order {
    opacity: .55;
}

.planning-day > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 30px;
    margin-bottom: 7px;
    color: #64748b;
    font-size: 12px;
}

.planning-day > header strong {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: var(--ink);
    font-size: 13px;
}

.planning-day.is-today {
    background: #f5f9fe;
    box-shadow: inset 0 0 0 2px rgba(23, 82, 150, .28);
}

.planning-day.is-today > header strong {
    background: var(--brand);
    color: #fff;
}

.planning-day-orders {
    display: grid;
    gap: 6px;
}

.planning-order {
    display: grid;
    gap: 2px;
    overflow: hidden;
    border-left: 4px solid #64748b;
    border-radius: 7px;
    padding: 7px 8px;
    background: #eef2f6;
    color: #334155;
    font-size: 11px;
    line-height: 1.35;
    text-decoration: none;
}

.planning-order:hover {
    filter: brightness(.97);
    box-shadow: 0 4px 10px rgba(31, 36, 40, .08);
}

.planning-order strong,
.planning-order span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.planning-order strong {
    color: #172033;
    font-size: 12px;
}

.planning-order-time {
    font-weight: 850;
}

.planning-order-scheduled {
    border-left-color: #175296;
    background: #eaf2fb;
}

.planning-order-in_progress {
    border-left-color: #d97706;
    background: #fff5df;
}

.planning-order-waiting_for_parts {
    border-left-color: #7c3aed;
    background: #f3edff;
}

.planning-order-completed {
    border-left-color: #15803d;
    background: #eaf7ef;
}

.planning-order-cancelled {
    border-left-color: #b42318;
    background: #fff0ef;
}

.planning-order-new {
    border-left-color: #64748b;
    background: #eef2f6;
}

.planning-empty {
    padding: 8px 0;
    color: #94a3b8;
    font-size: 11px;
    text-align: center;
}

/* Clear status choices on the order form. */
.order-status-picker .fi-fo-toggle-buttons-btn-ctn {
    min-width: 0;
}

.order-status-picker .fi-btn {
    width: 100%;
    min-height: 46px;
    border: 1px solid;
    border-radius: 9px;
    font-weight: 800;
    justify-content: center;
    box-shadow: none;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.order-status-picker input + .fi-btn {
    border-color: #d5dde6;
    background: #fff !important;
    color: #334155 !important;
}

.order-status-picker input + .fi-btn:hover {
    border-color: #94a3b8;
    background: #f8fafc !important;
}

.order-status-picker input[value="new"]:checked + .fi-btn {
    border-color: #475569;
    background: #475569 !important;
    color: #fff !important;
}

.order-status-picker input[value="quote_sent"]:checked + .fi-btn {
    border-color: #d97706;
    background: #d97706 !important;
    color: #fff !important;
}

.order-status-picker input[value="quote_accepted"]:checked + .fi-btn {
    border-color: #0f766e;
    background: #0f766e !important;
    color: #fff !important;
}

.order-status-picker input[value="scheduled"]:checked + .fi-btn {
    border-color: #175296;
    background: #175296 !important;
    color: #fff !important;
}

.order-status-picker input[value="in_progress"]:checked + .fi-btn {
    border-color: #b76300;
    background: #b76300 !important;
    color: #fff !important;
}

.order-status-picker input[value="waiting_for_parts"]:checked + .fi-btn {
    border-color: #6d28d9;
    background: #6d28d9 !important;
    color: #fff !important;
}

.order-status-picker input[value="completed"]:checked + .fi-btn {
    border-color: #15803d;
    background: #15803d !important;
    color: #fff !important;
}

.order-status-picker input[value="cancelled"]:checked + .fi-btn {
    border-color: #b42318;
    background: #b42318 !important;
    color: #fff !important;
}

.order-status-picker input:focus-visible + .fi-btn {
    outline: 3px solid rgba(23, 82, 150, .2);
    outline-offset: 2px;
}

@media (max-width: 760px) {
    .planning-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .planning-period {
        flex-wrap: wrap;
    }

    .planning-period h2 {
        width: 100%;
        margin: 8px 0 0;
    }

    .planning-view-switch {
        align-self: flex-start;
    }
}

/* Background & Body Font */
.fi-simple-layout {
    background: var(--bg) !important;
    font-family: Arial, sans-serif !important;
    color: var(--ink) !important;

    /* Brand blue for login page components (buttons, focus rings, checkboxes and links). */
    --primary-50: 239 246 255 !important;
    --primary-100: 219 234 254 !important;
    --primary-200: 191 219 254 !important;
    --primary-300: 147 197 253 !important;
    --primary-400: 59 130 246 !important;
    --primary-500: 23 82 150 !important;
    --primary-600: 23 82 150 !important;
    --primary-700: 16 59 112 !important;
    --primary-800: 15 47 87 !important;
    --primary-900: 13 39 72 !important;
    --primary-950: 8 25 48 !important;

    /* Also support hex primary colors if Tailwind expects hex */
    --color-primary-50: #eff6ff !important;
    --color-primary-100: #dbeafe !important;
    --color-primary-200: #bfdbfe !important;
    --color-primary-300: #93c5fd !important;
    --color-primary-400: #3b82f6 !important;
    --color-primary-500: var(--brand) !important;
    --color-primary-600: var(--brand-dark) !important;
    --color-primary-700: var(--brand-dark) !important;
}

/* Centered Main Card */
.fi-simple-main {
    background: var(--white) !important;
    border: 1px solid var(--line) !important;
    border-radius: 10px !important;
    padding: 34px !important;
    box-shadow: 0 14px 34px rgba(31, 36, 40, .06) !important;
    width: 100% !important;
    max-width: 448px !important;
}

/* Header & Logo styling */
.fi-simple-header {
    margin-bottom: 24px !important;
}

.fi-simple-header .fi-logo {
    display: block !important;
    width: 260px !important;
    max-width: 100% !important;
    height: auto !important;
    margin: 0 auto 26px !important;
    object-fit: contain !important;
}

/* Heading (Title) */
.fi-simple-header-heading {
    margin: 0 !important;
    font-size: 26px !important;
    font-weight: bold !important;
    line-height: 1.25 !important;
    text-align: center !important;
    color: var(--ink) !important;
}

/* Subheading (Description) */
.fi-simple-header-subheading {
    margin: 12px 0 0 !important;
    color: var(--muted) !important;
    line-height: 1.6 !important;
    text-align: center !important;
}

/* Text Inputs (Email & Password) */
.fi-simple-layout input[type="email"],
.fi-simple-layout input[type="password"],
.fi-simple-layout input[type="text"] {
    width: 100% !important;
    min-height: 46px !important;
    border: 1px solid var(--line) !important;
    border-radius: 8px !important;
    padding: 0 12px !important;
    font-size: 16px !important;
    box-shadow: none !important;
    background-color: var(--white) !important;
    color: var(--ink) !important;
}

.fi-simple-layout input[type="email"]:focus,
.fi-simple-layout input[type="password"]:focus,
.fi-simple-layout input[type="text"]:focus {
    outline: 2px solid rgba(23, 82, 150, .22) !important;
    border-color: var(--brand) !important;
    box-shadow: none !important;
    --tw-ring-offset-width: 0px !important;
    --tw-ring-width: 0px !important;
    --tw-ring-color: transparent !important;
}

/* Login remember-me checkbox. */
.fi-simple-layout input[type="checkbox"].fi-checkbox-input {
    appearance: none !important;
    width: 18px !important;
    height: 18px !important;
    flex: 0 0 18px !important;
    border: 1px solid #9ca3af !important;
    border-radius: 4px !important;
    background-color: var(--white) !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-size: 12px 12px !important;
    cursor: pointer !important;
}

.fi-simple-layout input[type="checkbox"].fi-checkbox-input:checked {
    border-color: var(--brand) !important;
    background-color: var(--brand) !important;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3.5 8.5 6.5 11.5 12.5 4.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
}

.fi-simple-layout input[type="checkbox"].fi-checkbox-input:focus-visible {
    outline: 3px solid rgba(23, 82, 150, .2) !important;
    outline-offset: 2px !important;
}

/* Labels */
.fi-simple-layout label {
    font-weight: 800 !important;
    color: var(--ink) !important;
}

/* Submit Action Button */
.fi-simple-layout button[type="submit"],
.fi-simple-layout .fi-btn {
    min-height: 46px !important;
    border: 0 !important;
    border-radius: 8px !important;
    background: var(--brand) !important;
    color: var(--white) !important;
    font-weight: 900 !important;
    font-size: 16px !important;
    cursor: pointer !important;
    box-shadow: none !important;
    width: 100% !important;
    padding: 0 24px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.fi-simple-layout button[type="submit"]:hover,
.fi-simple-layout .fi-btn:hover {
    background: var(--brand-dark) !important;
}

/* Text links (e.g., Back to Login, Forgot Password, etc.) */
.fi-simple-layout a {
    color: var(--brand) !important;
    font-weight: 700 !important;
}

.fi-simple-layout a:hover {
    color: var(--brand-dark) !important;
    text-decoration: underline !important;
}

[x-cloak] {
    display: none !important;
}

.fi-ta-selection-indicator {
    display: none !important;
}

.max-unsaved-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, .58);
    backdrop-filter: blur(2px);
}

.max-unsaved-dialog {
    width: 100%;
    max-width: 520px;
    padding: 28px;
    border: 1px solid rgba(15, 23, 42, .12);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
}

.max-unsaved-title {
    margin: 0;
    color: #111827;
    font-size: 21px;
    font-weight: 800;
    line-height: 1.3;
}

.max-unsaved-description {
    margin: 10px 0 0;
    color: #4b5563;
    font-size: 14px;
    line-height: 1.6;
}

.max-unsaved-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 26px;
}

.max-unsaved-button {
    min-height: 42px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 750;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.max-unsaved-button-back {
    background: transparent;
    color: #4b5563;
}

.max-unsaved-button-back:hover {
    background: #f3f4f6;
}

.max-unsaved-button-discard {
    border-color: #d1d5db;
    background: #fff;
    color: #374151;
}

.max-unsaved-button-discard:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.max-unsaved-button-save {
    background: #175296;
    color: #fff;
}

.max-unsaved-button-save:hover {
    background: #123f74;
}

@media (max-width: 560px) {
    .max-unsaved-dialog {
        padding: 22px;
    }

    .max-unsaved-actions {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .max-unsaved-button {
        width: 100%;
    }
}
