/* LK.Cheques — tenant app design system */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

[data-theme="corporate"] {
    /* DaisyUI 4 expects OKLCH in --p/--s/etc; keep HSL for our own CSS and
       set --fallback-* hex so DaisyUI components still get valid colors. */
    --p: 216 79% 20%;
    --pc: 210 40% 98%;
    --s: 122 39% 49%;
    --sc: 0 0% 100%;
    --a: 122 39% 49%;
    --n: 216 79% 14%;
    --b1: 210 25% 99%;
    --b2: 214 22% 96%;
    --b3: 214 18% 90%;
    --bc: 216 35% 18%;
    --fallback-p: #0b2a5b;
    --fallback-pc: #f1f5f9;
    --fallback-s: #4caf50;
    --fallback-sc: #ffffff;
    --fallback-a: #4caf50;
    --fallback-ac: #ffffff;
    --fallback-n: #071d3f;
    --fallback-nc: #f1f5f9;
    --fallback-b1: #fafbfc;
    --fallback-b2: #f1f4f8;
    --fallback-b3: #e2e8f0;
    --fallback-bc: #1e293b;
    --rounded-box: 0.625rem;
    --rounded-btn: 0.4375rem;
}

/* Native-style permission ticks — do not rely on DaisyUI checkbox gradients */
input[type="checkbox"].perm-check {
    -webkit-appearance: none;
    appearance: none;
    width: 1.125rem;
    height: 1.125rem;
    margin: 0;
    flex-shrink: 0;
    border: 2px solid #0b2a5b;
    border-radius: 0.25rem;
    background-color: #ffffff;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 0.75rem 0.75rem;
    cursor: pointer;
    vertical-align: middle;
}

input[type="checkbox"].perm-check:checked {
    background-color: #0b2a5b;
    border-color: #0b2a5b;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5L6.5 11.5L12.5 4.5'/%3E%3C/svg%3E");
}

input[type="checkbox"].perm-check:focus-visible {
    outline: 2px solid rgb(76 175 80 / 55%);
    outline-offset: 2px;
}

/* DaisyUI .checkbox elsewhere — same solid tick, ignore broken OKLCH */
[data-theme="corporate"] input[type="checkbox"].checkbox {
    -webkit-appearance: none;
    appearance: none;
    width: 1.125rem;
    height: 1.125rem;
    margin: 0;
    flex-shrink: 0;
    border: 2px solid #0b2a5b;
    border-radius: 0.25rem;
    background-color: #ffffff;
    background-image: none;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 0.75rem 0.75rem;
    cursor: pointer;
    animation: none !important;
}

[data-theme="corporate"] input[type="checkbox"].checkbox:checked,
[data-theme="corporate"] input[type="checkbox"].checkbox[aria-checked="true"] {
    background-color: #0b2a5b;
    border-color: #0b2a5b;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5L6.5 11.5L12.5 4.5'/%3E%3C/svg%3E");
    animation: none !important;
}

[data-theme="corporate"] .btn-primary {
    background-color: #0b2a5b;
    border-color: #0b2a5b;
    color: #ffffff;
}

[data-theme="corporate"] .btn-primary:hover {
    background-color: #071d3f;
    border-color: #071d3f;
}

[data-theme="corporate"] .btn-secondary {
    background-color: #4caf50;
    border-color: #4caf50;
    color: #ffffff;
}

/* Radios used on the same form */
[data-theme="corporate"] .radio,
[data-theme="corporate"] .radio-primary {
    -webkit-appearance: none;
    appearance: none;
    width: 1.125rem;
    height: 1.125rem;
    border: 2px solid #0b2a5b;
    border-radius: 9999px;
    background-color: #ffffff;
    cursor: pointer;
}

[data-theme="corporate"] .radio:checked,
[data-theme="corporate"] .radio-primary:checked {
    border-color: #0b2a5b;
    background-color: #ffffff;
    box-shadow: inset 0 0 0 0.28rem #0b2a5b;
}

:root {
    --brand-navy: #0b2a5b;
    --brand-navy-deep: #071d3f;
    --brand-green: #4caf50;
    --font-ui: 'Plus Jakarta Sans', system-ui, sans-serif;
    --font-display: 'Fraunces', Georgia, serif;
    --sidebar-w: 15.5rem;
    --topbar-h: 3.25rem;
    --surface-border: hsl(214 18% 88%);
    --surface-shadow: 0 1px 2px rgb(11 42 91 / 6%), 0 4px 16px rgb(11 42 91 / 4%);
}

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-ui);
    font-feature-settings: 'kern' 1;
    -webkit-font-smoothing: antialiased;
}

.font-display { font-family: var(--font-display); }

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid rgb(76 175 80 / 55%);
    outline-offset: 2px;
}

.skip-link {
    position: fixed;
    z-index: 10000;
    top: .75rem;
    left: .75rem;
    padding: .6rem 1rem;
    color: white;
    background: var(--brand-navy);
    border-radius: .4375rem;
    transform: translateY(-160%);
}
.skip-link:focus { transform: none; }

.btn, .input, .select, .file-input { min-height: 2.5rem; font-family: var(--font-ui); }
.btn-sm, .input-sm, .select-sm { min-height: 2.125rem; }

/* App canvas */
.app-canvas {
    background:
        radial-gradient(ellipse 80% 60% at 100% 0%, hsl(216 79% 20% / 4%) 0%, transparent 55%),
        radial-gradient(ellipse 60% 50% at 0% 100%, hsl(122 39% 49% / 5%) 0%, transparent 50%),
        hsl(var(--b2));
    min-height: 100vh;
}

.app-main {
    animation: pageEnter 0.2s ease-out;
    padding: 0.875rem 1rem 1.5rem;
    max-width: 90rem;
}

@media (min-width: 1024px) {
    .app-main { padding: 1rem 1.5rem 2rem; }
}

@keyframes pageEnter {
    from { opacity: 0; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Sidebar — navy rail */
.drawer-side aside.app-sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--brand-navy-deep) 0%, var(--brand-navy) 100%);
    color: hsl(210 40% 96%);
    border-right: 1px solid hsl(216 79% 28% / 40%);
}

.sidebar-brand {
    padding: 1.125rem 1rem 0.875rem;
    border-bottom: 1px solid hsl(210 40% 98% / 10%);
}

.sidebar-brand-mark {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.sidebar-brand-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    background: hsl(var(--s));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.sidebar-brand-name {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
    color: white;
}

.sidebar-brand-tag {
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.55;
    margin-top: 0.125rem;
}

.sidebar-section-title {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: hsl(210 40% 98% / 0.4);
    padding: 0.875rem 1rem 0.25rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.75rem;
    margin: 0.1rem 0.5rem;
    border-radius: 0.4375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: hsl(210 40% 98% / 0.72);
    transition: background 0.12s, color 0.12s;
    border-left: 2px solid transparent;
}

.sidebar-link:hover {
    background: hsl(210 40% 98% / 0.08);
    color: white;
}

.sidebar-link.active {
    background: hsl(210 40% 98% / 0.12);
    color: white;
    border-left-color: hsl(var(--s));
    font-weight: 600;
}

.sidebar-link.cta {
    margin-top: 0.25rem;
    margin-bottom: 0.35rem;
    background: hsl(var(--s));
    color: white;
    font-weight: 600;
    border-left-color: transparent;
    box-shadow: 0 2px 8px hsl(122 39% 49% / 35%);
}

.sidebar-link.cta:hover {
    background: hsl(122 39% 44%);
    color: white;
}

.sidebar-link.cta.active {
    background: hsl(122 39% 42%);
    box-shadow: 0 2px 10px hsl(122 39% 49% / 45%);
}

.sidebar-icon {
    width: 1.05rem;
    height: 1.05rem;
    flex-shrink: 0;
    opacity: 0.75;
}

.sidebar-link.active .sidebar-icon,
.sidebar-link.cta .sidebar-icon { opacity: 1; }

.sidebar-trial-banner {
    margin: 0.75rem 0.5rem;
    padding: 0.625rem 0.75rem;
    border-radius: 0.4375rem;
    font-size: 0.75rem;
    line-height: 1.4;
    border: 1px solid hsl(210 40% 98% / 0.15);
    background: hsl(210 40% 98% / 0.08);
    color: white;
}

.sidebar-trial-banner.is-critical {
    background: hsl(0 70% 45% / 0.25);
    border-color: hsl(0 70% 60% / 0.4);
}

/* Top bar */
.app-topbar {
    min-height: var(--topbar-h);
    background: hsl(var(--b1) / 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--surface-border);
    padding-inline: 0.875rem;
}

@media (min-width: 1024px) {
    .app-topbar { padding-inline: 1.25rem; }
}

.app-topbar-context {
    font-size: 0.8125rem;
    color: hsl(var(--bc) / 0.55);
}

.app-topbar-context strong {
    color: hsl(var(--bc));
    font-weight: 600;
}

.menu li > button[type="submit"] {
    width: 100%;
    justify-content: flex-start;
    border-radius: var(--rounded-btn, 0.5rem);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 400;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
}

.menu li > button[type="submit"]:hover {
    background-color: hsl(var(--b2));
}

/* Page header */
.page-header {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.875rem;
    border-bottom: 1px solid var(--surface-border);
}

@media (min-width: 640px) {
    .page-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
    }
}

.page-header__eyebrow {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: hsl(var(--bc) / 0.45);
    margin-bottom: 0.2rem;
}

.page-header__title {
    font-family: var(--font-display);
    font-size: 1.375rem;
    font-weight: 600;
    line-height: 1.25;
    color: hsl(var(--bc));
    letter-spacing: -0.01em;
}

.page-header__subtitle {
    font-size: 0.8125rem;
    color: hsl(var(--bc) / 0.55);
    margin-top: 0.25rem;
    max-width: 42rem;
}

.page-header__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Surfaces */
.app-surface {
    background: hsl(var(--b1));
    border: 1px solid var(--surface-border);
    border-radius: var(--rounded-box);
    box-shadow: var(--surface-shadow);
}

.app-surface--flush { overflow: hidden; }

.card-elevated,
.card.app-surface {
    border: 1px solid var(--surface-border);
    box-shadow: var(--surface-shadow);
    background: hsl(var(--b1));
}

.card-elevated .card-body,
.app-surface .card-body {
    padding: 1rem 1.125rem;
}

@media (min-width: 1024px) {
    .card-elevated .card-body,
    .app-surface .card-body { padding: 1.125rem 1.25rem; }
}

/* Stat cards */
.stat-card {
    border: 1px solid var(--surface-border);
    background: hsl(var(--b1));
    border-radius: var(--rounded-box);
    padding: 0.875rem 1rem;
    box-shadow: var(--surface-shadow);
    transition: box-shadow 0.15s;
}

.stat-card:hover { box-shadow: 0 4px 14px rgb(11 42 91 / 8%); }

.stat-card-icon {
    width: 2.125rem;
    height: 2.125rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card .stat-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: hsl(var(--bc) / 0.5);
}

.stat-card .stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Data tables */
.data-table-wrap { overflow-x: auto; }

.table.data-table th,
.table th {
    white-space: nowrap;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: hsl(var(--bc) / 0.5);
    background: hsl(var(--b2));
    padding: 0.5rem 0.75rem;
}

.table.data-table td,
.table td {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background: hsl(var(--p) / 0.04);
    cursor: pointer;
}

.table-zebra tbody tr:nth-child(even) {
    background: hsl(var(--b2) / 0.5);
}

.amount-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* Filter bar */
.filter-bar {
    background: hsl(var(--b1));
    border: 1px solid var(--surface-border);
    border-radius: var(--rounded-box);
    padding: 0.75rem 1rem;
    margin-bottom: 0.875rem;
    box-shadow: var(--surface-shadow);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 2rem 1.25rem;
}

.empty-state-icon {
    width: 2.75rem;
    height: 2.75rem;
    margin: 0 auto 0.75rem;
    opacity: 0.3;
    color: hsl(var(--p));
}

.empty-state p {
    font-size: 0.875rem;
    color: hsl(var(--bc) / 0.55);
    margin-bottom: 0.875rem;
}

/* Alerts */
.app-alert {
    margin-bottom: 0.875rem;
    font-size: 0.875rem;
    border-radius: var(--rounded-box);
}

/* Status badges */
.status-badge {
    text-transform: capitalize;
    font-size: 0.6875rem;
    font-weight: 600;
}

/* Form sections */
.form-section-title {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: hsl(var(--bc) / 0.45);
    margin-bottom: 0.625rem;
    padding-bottom: 0.375rem;
    border-bottom: 1px solid var(--surface-border);
}

/* Quick print steps */
.step-indicator {
    display: flex;
    gap: 0.375rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.step-pill {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.3rem 0.75rem;
    border-radius: 9999px;
    background: hsl(var(--b2));
    color: hsl(var(--bc) / 0.45);
    border: 1px solid var(--surface-border);
}

.step-pill.active {
    background: hsl(var(--p));
    color: hsl(var(--pc));
    border-color: hsl(var(--p));
}

.step-pill.done {
    background: hsl(var(--s) / 0.12);
    color: hsl(var(--s));
    border-color: hsl(var(--s) / 0.3);
}

/* Dashboard plan strip */
.plan-strip {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    padding: 0.875rem 1.125rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, hsl(var(--p) / 0.06) 0%, hsl(var(--s) / 0.06) 100%);
    border: 1px solid var(--surface-border);
    border-radius: var(--rounded-box);
}

@media (min-width: 1024px) {
    .plan-strip {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.625rem;
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1280px) {
    .kpi-grid { grid-template-columns: repeat(5, 1fr); }
}

.dashboard-grid {
    display: grid;
    gap: 0.875rem;
}

@media (min-width: 1024px) {
    .dashboard-grid--split { grid-template-columns: 1fr 1fr; }
}

/* Activity timeline */
.activity-timeline li {
    position: relative;
    padding-left: 0.875rem;
    border-left: 2px solid var(--surface-border);
}

.activity-timeline li:last-child { border-left-color: transparent; }

/* Quick print */
.quick-print-form .label { padding-bottom: 0.1rem; min-height: auto; }
.quick-print-sidebar .invoice-pick { cursor: pointer; }
.quick-print-sidebar .invoice-pick-active {
    background: hsl(var(--p) / 0.08);
    border-left: 3px solid hsl(var(--p));
    padding-left: calc(0.75rem - 3px);
}
.quick-print-sidebar-list { scrollbar-width: thin; }
.quick-print-top-row .card { height: 100%; }
.quick-print-sidebar .quick-print-sidebar-list { min-height: 8rem; }

/* Layout designer */
.field-draggable {
    z-index: 10;
    min-width: 2.75rem;
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    touch-action: none;
}
.designer-scroll { overflow: auto; max-width: 100%; padding: .5rem; }

.mono-time {
    font-family: ui-monospace, monospace;
    font-size: 0.75rem;
}

/* Auth */
.auth-split {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr;
}

@media (min-width: 1024px) {
    .auth-split { grid-template-columns: 1.05fr 1fr; }
}

.auth-brand-panel {
    background: linear-gradient(145deg, var(--brand-navy-deep) 0%, var(--brand-navy) 55%, #16427d 100%);
    color: hsl(210 40% 98%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2.5rem 2rem;
    position: relative;
    overflow: hidden;
}

.auth-brand-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 15% 85%, rgb(76 175 80 / 16%) 0%, transparent 45%);
}

.auth-brand-panel h1 {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
}

.auth-form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: hsl(var(--b2));
}

.auth-form-card {
    background: hsl(var(--b1));
    border: 1px solid var(--surface-border);
    border-radius: var(--rounded-box);
    box-shadow: var(--surface-shadow);
    padding: 1.5rem;
    width: 100%;
}

/* Modals */
dialog.modal {
    margin: auto;
    padding: 0;
    border: none;
    background: transparent;
    max-width: 100vw;
    max-height: 100vh;
    z-index: 9999;
}

dialog.modal .modal-box {
    background-color: hsl(var(--b1));
    position: relative;
    z-index: 1;
    border: 1px solid var(--surface-border);
}

dialog.modal::backdrop { background: rgba(7, 29, 63, 0.55); }

@media print {
    .no-print { display: none !important; }
}

@media (max-width: 639px) {
    .card-body { padding: 0.875rem; }
    .table { min-width: 40rem; }
    .app-main { padding: 0.75rem; }
    .page-header__title { font-size: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}
