:root {
    --dalalia-brand: #168fc8;
    --dalalia-brand-dark: #1173a3;
}

html {
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
    font: inherit;
}

body button {
    border-radius: 0.75rem;
    font-weight: 600;
    transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

body button:active:not(:disabled) {
    transform: translateY(1px);
}

body button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

body form input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
body form select,
body form textarea {
    min-height: 2.75rem;
    border: 1px solid #aab5cf;
    border-radius: 0.75rem;
    background-color: #fff;
    padding: 0.625rem 0.875rem;
    color: #172036;
    font-size: 0.875rem;
    box-shadow: 0 1px 2px rgb(16 23 42 / 5%);
    transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

body form textarea {
    min-height: 5rem;
}

body form input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):focus,
body form select:focus,
body form textarea:focus {
    border-color: var(--dalalia-brand);
    outline: none;
    box-shadow: 0 0 0 4px rgb(22 143 200 / 15%);
}

body form input[aria-invalid="true"],
body form select[aria-invalid="true"],
body form textarea[aria-invalid="true"] {
    border-color: #f87171;
}

body form input[type="checkbox"],
body form input[type="radio"] {
    accent-color: var(--dalalia-brand);
}

body form input[type="file"] {
    min-height: auto;
    padding: 0.5rem;
}

body button[class*="bg-brand-"],
body a[class*="bg-brand-"] {
    box-shadow: 0 1px 2px rgb(16 23 42 / 12%);
}

body button[class*="bg-brand-"]:hover:not(:disabled),
body a[class*="bg-brand-"]:hover {
    box-shadow: 0 4px 12px rgb(17 115 163 / 20%);
}

body label {
    color: #34446a;
    font-weight: 500;
}

[data-feather],
.ui-icon {
    width: 1.125rem;
    height: 1.125rem;
    flex: none;
    stroke-width: 1.8;
}

[x-cloak] {
    display: none !important;
}

:focus-visible {
    outline: 2px solid var(--dalalia-brand);
    outline-offset: 2px;
}

html.dark body {
    background-color: #10172a !important;
    color: #e5e7eb !important;
}

html.dark .bg-cream,
html.dark .bg-cream\/85,
html.dark .bg-white {
    background-color: #172036 !important;
}

html.dark .bg-slate-50,
html.dark .bg-navy-50 {
    background-color: #1f2a44 !important;
}

html.dark .bg-slate-100,
html.dark .bg-navy-100 {
    background-color: #2a3857 !important;
}

html.dark .text-ink,
html.dark .text-navy-700,
html.dark .text-navy-800,
html.dark .text-slate-600,
html.dark .text-slate-700,
html.dark .text-slate-800,
html.dark .text-slate-900 {
    color: #e5e7eb !important;
}

html.dark .text-slate-400,
html.dark .text-slate-500,
html.dark .text-navy-400 {
    color: #aab5cf !important;
}

html.dark label,
html.dark .text-ink {
    color: #e5e7eb;
}

html.dark .border-slate-100,
html.dark .border-slate-200,
html.dark .border-slate-300,
html.dark .border-navy-100 {
    border-color: #34446a !important;
}

html.dark form input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
html.dark form select,
html.dark form textarea {
    border-color: #4f6088;
    background-color: #172036;
    color: #e5e7eb;
}

html.dark input:not([type="checkbox"]):not([type="radio"]),
html.dark select,
html.dark textarea {
    border-color: #4f6088;
    background-color: #172036;
    color: #e5e7eb;
}

html.dark table thead {
    background-color: #172036;
}

html.dark table tbody tr {
    border-color: #34446a;
}

html.dark .bg-emerald-50 {
    background-color: rgb(16 185 129 / 12%);
}

html.dark .bg-amber-50 {
    background-color: rgb(245 158 11 / 12%);
}

html.dark .bg-rose-50 {
    background-color: rgb(244 63 94 / 12%);
}

html.dark .bg-red-50 {
    background-color: rgb(239 68 68 / 12%);
}

html.dark input::placeholder,
html.dark textarea::placeholder {
    color: #aab5cf;
}

html.dark .dataTables_wrapper,
html.dark .dataTables_filter input,
html.dark .dataTables_length select {
    color: #e5e7eb;
}

html.dark .dataTables_filter input,
html.dark .dataTables_length select {
    border-color: #4f6088;
    background-color: #172036;
    color: #e5e7eb;
}

/* ---------------------------------------------------------------------------
   Dark mode: complete colour mapping.
   Pages use light-mode Tailwind colours. In dark mode every light tint
   background becomes a soft dark tint, and every dark text colour becomes the
   light (-300) shade of the same hue, so text keeps contrast on any surface.
   Hover variants are repeated with higher specificity so hovers still work.
   --------------------------------------------------------------------------- */
html.dark .bg-slate-200 { background-color: #2a3857 !important; }
/* dark buttons would vanish on dark cards: lift them to a lighter navy */
html.dark .bg-slate-900,
html.dark .bg-navy-800,
html.dark .bg-ink { background-color: #34446a !important; }
html.dark .hover\:bg-navy-700:hover,
html.dark .hover\:bg-brand-700.bg-ink:hover { background-color: #4f6088 !important; }
html.dark .bg-brand-50  { background-color: rgb(22 143 200 / 14%) !important; }
html.dark .bg-brand-100 { background-color: rgb(22 143 200 / 22%) !important; }
html.dark .bg-emerald-100 { background-color: rgb(16 185 129 / 20%) !important; }
html.dark .bg-amber-100 { background-color: rgb(245 158 11 / 20%) !important; }
html.dark .bg-rose-100  { background-color: rgb(244 63 94 / 20%) !important; }

html.dark .hover\:bg-slate-50:hover,
html.dark .hover\:bg-slate-100:hover,
html.dark .hover\:bg-navy-50:hover,
html.dark .hover\:bg-white:hover { background-color: #2a3857 !important; }
html.dark .hover\:bg-slate-200:hover { background-color: #34446a !important; }
html.dark .hover\:bg-slate-700:hover { background-color: #4f6088 !important; }
html.dark .hover\:bg-brand-50:hover,
html.dark .hover\:bg-brand-100:hover { background-color: rgb(22 143 200 / 28%) !important; }
html.dark .hover\:bg-emerald-50:hover,
html.dark .hover\:bg-emerald-100:hover { background-color: rgb(16 185 129 / 26%) !important; }
html.dark .hover\:bg-amber-50:hover,
html.dark .hover\:bg-amber-100:hover { background-color: rgb(245 158 11 / 26%) !important; }
html.dark .hover\:bg-rose-50:hover,
html.dark .hover\:bg-rose-100:hover,
html.dark .hover\:bg-red-50:hover { background-color: rgb(244 63 94 / 26%) !important; }

html.dark .text-brand-500, html.dark .text-brand-600, html.dark .text-brand-700, html.dark .text-brand-800,
html.dark .hover\:text-brand-600:hover, html.dark .hover\:text-brand-700:hover, html.dark .hover\:text-brand-800:hover { color: #63bbe3 !important; }
html.dark .text-navy-600, html.dark .text-navy-900 { color: #d5dbe8 !important; }
html.dark .text-gray-600 { color: #d1d5db !important; }
html.dark .text-blue-600 { color: #93c5fd !important; }
html.dark .text-gold-600 { color: #e8c56a !important; }
html.dark .text-emerald-600, html.dark .text-emerald-700, html.dark .text-emerald-800, html.dark .text-emerald-950,
html.dark .hover\:text-emerald-700:hover { color: #6ee7b7 !important; }
html.dark .text-amber-600, html.dark .text-amber-700, html.dark .text-amber-800, html.dark .text-amber-900, html.dark .text-amber-950,
html.dark .hover\:text-amber-700:hover { color: #fcd34d !important; }
html.dark .text-rose-500, html.dark .text-rose-600, html.dark .text-rose-700, html.dark .text-rose-800,
html.dark .hover\:text-rose-700:hover { color: #fda4af !important; }
html.dark .text-red-600, html.dark .text-red-700, html.dark .text-red-800, html.dark .text-red-950,
html.dark .hover\:text-red-700:hover { color: #fca5a5 !important; }

html.dark .border-navy-200 { border-color: #34446a !important; }
html.dark .border-brand-100, html.dark .border-brand-200, html.dark .border-brand-300 { border-color: rgb(22 143 200 / 40%) !important; }
html.dark .border-emerald-100, html.dark .border-emerald-200 { border-color: rgb(16 185 129 / 40%) !important; }
html.dark .border-amber-200 { border-color: rgb(245 158 11 / 40%) !important; }
html.dark .border-rose-100, html.dark .border-rose-200, html.dark .border-red-200 { border-color: rgb(244 63 94 / 40%) !important; }

html.dark .ring-slate-200, html.dark .ring-slate-300 { --tw-ring-color: #34446a; }
html.dark .ring-brand-200, html.dark .ring-brand-300 { --tw-ring-color: rgb(22 143 200 / 45%); }
html.dark .ring-amber-200, html.dark .ring-amber-300 { --tw-ring-color: rgb(245 158 11 / 45%); }
html.dark .ring-rose-200 { --tw-ring-color: rgb(244 63 94 / 45%); }

/* White chips laid over photos (Cover / Remove) stay white, so keep their text dark. */
html.dark .bg-white\/90.text-ink,
html.dark .bg-white\/90 .text-ink { color: #1f2a44 !important; }
html.dark .bg-white\/90.text-rose-600 { color: #e11d48 !important; }

/* DataTables (CDN) has its own dark theme that leaves the input text dark. */
html.dark .dataTables_wrapper .dataTables_filter input,
html.dark .dataTables_wrapper .dataTables_length select { color: #e5e7eb !important; background-color: #172036 !important; }
html.dark table.dataTable thead th { color: #aab5cf; }

.tabular {
    font-variant-numeric: tabular-nums;
}

.ui-toast {
    animation: ui-toast-in 180ms ease-out both;
}

.ui-toast.is-leaving {
    animation: ui-toast-out 180ms ease-in both;
}

@keyframes ui-toast-in {
    from { opacity: 0; transform: translateY(-0.5rem) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ui-toast-out {
    to { opacity: 0; transform: translateY(-0.5rem) scale(0.98); }
}

.ui-confirm-dialog {
    width: min(28rem, calc(100vw - 2rem));
    max-width: none;
    border: 1px solid #d5dbe8;
    border-radius: 1rem;
    padding: 1.5rem;
    color: #1f2a44;
    box-shadow: 0 24px 60px rgb(10 15 28 / 30%);
}

.ui-confirm-dialog::backdrop {
    background: rgb(10 15 28 / 60%);
    backdrop-filter: blur(3px);
}

.ui-confirm-dialog[open] {
    animation: ui-toast-in 150ms ease-out both;
}

html.dark .ui-confirm-dialog {
    border-color: #34446a;
    background: #172036;
    color: #e5e7eb;
}

.ui-toast-progress {
    animation: ui-toast-progress 6s linear forwards;
}

.sweet-alert {
    border-radius: 1.25rem;
    padding: 1.75rem;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    box-shadow: 0 24px 60px rgb(10 15 28 / 30%);
}

.sweet-alert h2 {
    color: #1f2a44;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    font-size: 1.25rem;
    line-height: 1.6;
}

.sweet-alert p {
    color: #4f6088;
    line-height: 1.6;
    white-space: pre-line;
}

html.dark .sweet-alert {
    background: #172036;
}

html.dark .sweet-alert h2 {
    color: #f8fafc;
}

html.dark .sweet-alert p {
    color: #cbd5e1;
}

html.dark .sweet-alert .sa-icon.sa-success::before,
html.dark .sweet-alert .sa-icon.sa-success::after,
html.dark .sweet-alert .sa-icon.sa-success .sa-fix {
    background-color: #172036;
}

html.dark .sweet-alert .sa-error-container {
    background-color: #10172a;
}

html.dark .sweet-alert button.cancel {
    background-color: #34446a;
    color: #f8fafc;
}

html.dark .sweet-alert button.cancel:hover {
    background-color: #4f6088;
}

.sweet-alert button {
    border-radius: 0.75rem;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    transition: filter 150ms ease, transform 150ms ease;
}

.sweet-alert button:hover {
    filter: brightness(0.94);
}

.sweet-alert button:active {
    transform: translateY(1px);
}

@keyframes ui-toast-progress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

.dataTables_wrapper {
    color: #34446a;
    font-size: 0.875rem;
}

.dataTables_filter input,
.dataTables_length select {
    margin-left: 0.4rem;
    border: 1px solid #d5dbe8;
    border-radius: 0.75rem;
    background: #fff;
    padding: 0.5rem 0.75rem;
    color: #172036;
}

.dataTables_filter input:focus,
.dataTables_length select:focus {
    border-color: var(--dalalia-brand);
    outline: 2px solid rgb(22 143 200 / 15%);
}

.dataTables_filter {
    margin-bottom: 0.75rem;
}

table.dataTable thead th,
table.dataTable.no-footer {
    border-bottom-color: #d5dbe8;
}

.dataTables_paginate .paginate_button.current,
.dataTables_paginate .paginate_button.current:hover,
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    border: 0 !important;
    border-radius: 0.75rem;
    background: var(--dalalia-brand-dark) !important;
    color: #fff !important;
}

.dataTables_info {
    color: #7a89ad;
    font-size: 0.8125rem;
}

#units-table th,
#units-table td {
    white-space: nowrap;
}

.dataTables_scrollBody {
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 640px) {
    .dataTables_length,
    .dataTables_filter,
    .dataTables_info,
    .dataTables_paginate {
        float: none !important;
        margin-bottom: 0.5rem;
        text-align: left !important;
    }

    .dataTables_filter input {
        width: 100%;
        margin-top: 0.25rem;
        margin-left: 0;
    }

    .dataTables_filter label {
        display: block;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
