/* Small overrides beyond Tailwind CDN defaults */
:root {
    --app-max-readable-width: 1920px;
    --app-wide-readable-width: 2200px;
    --app-page-pad: clamp(8px, 1vw, 22px);
    --app-control-height: 36px;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    min-width: 320px;
    overflow-x: hidden;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

table th { text-align: left; }
img, svg, video, canvas {
    max-width: 100%;
    height: auto;
}

button,
a,
input,
select,
textarea {
    touch-action: manipulation;
}

button,
a,
input,
select,
textarea {
    max-width: 100%;
}

input,
select,
textarea {
    min-width: 0;
}

.app-theme {
    color: #172033;
    background:
        radial-gradient(circle at 20% 8%, rgba(255, 255, 255, 0.78), transparent 24%),
        radial-gradient(circle at 76% 0%, rgba(105, 113, 229, 0.34), transparent 28%),
        linear-gradient(135deg, #dbe8ff 0%, #c8d8ff 48%, #e7dbff 100%) !important;
    background-attachment: fixed;
}

.app-theme main,
.app-theme section,
.app-theme form,
.app-theme .bg-white,
.app-theme table,
.app-theme img {
    overflow-wrap: anywhere;
}

.app-theme nav {
    border-color: rgba(255, 255, 255, 0.66) !important;
    background: rgba(255, 255, 255, 0.76) !important;
    box-shadow: 0 14px 36px rgba(70, 88, 170, 0.14) !important;
    backdrop-filter: blur(18px);
}

.app-theme footer {
    color: #5f6d8a !important;
}

.app-public-header {
    display: flex;
    align-items: center;
    min-height: 58px;
    padding: 8px 16px;
}

.app-public-header .app-logo {
    border-radius: 6px;
}

.login-compact-shell {
    margin-top: -12px;
}

.login-compact-card input {
    min-height: 38px;
}

.login-photo-panel {
    border-right: 1px solid rgba(173, 184, 220, 0.5);
}

.app-theme .bg-white {
    border: 1px solid rgba(255, 255, 255, 0.72);
    background-color: rgba(255, 255, 255, 0.84) !important;
    box-shadow: 0 18px 48px rgba(67, 84, 180, 0.14);
    backdrop-filter: blur(16px);
}

.app-theme form.bg-white,
.app-theme section.bg-white,
.app-theme div.bg-white.rounded-xl,
.app-theme div.bg-white.rounded-lg,
.app-theme .users-table-card {
    content-visibility: auto;
    contain-intrinsic-size: 1px 360px;
}

.app-theme .shadow,
.app-theme .shadow-sm,
.app-theme .shadow-xl,
.app-theme .shadow-2xl {
    box-shadow: 0 18px 48px rgba(67, 84, 180, 0.14) !important;
}

.app-theme input,
.app-theme select,
.app-theme textarea {
    border-color: #d9e0f6 !important;
    background: rgba(255, 255, 255, 0.9) !important;
    color: #172033;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.app-theme input:focus,
.app-theme select:focus,
.app-theme textarea:focus {
    border-color: #7f8df4 !important;
    box-shadow: 0 0 0 3px rgba(127, 141, 244, 0.18) !important;
    outline: none;
}

.app-theme .bg-blue-600,
.app-theme .bg-blue-700 {
    background: linear-gradient(135deg, #6477f2, #8c77ef) !important;
    box-shadow: 0 10px 24px rgba(100, 119, 242, 0.24);
}

.app-theme .bg-green-600 {
    background: linear-gradient(135deg, #28a86b, #57c39a) !important;
}

.app-theme .bg-gray-800,
.app-theme .bg-slate-950 {
    background: linear-gradient(135deg, #263149, #46506f) !important;
}

.app-theme .border,
.app-theme .border-b,
.app-theme .border-gray-200,
.app-theme .border-gray-300 {
    border-color: rgba(173, 184, 220, 0.72) !important;
}

.app-theme table thead,
.app-theme .bg-gray-50 {
    background-color: rgba(248, 250, 255, 0.72) !important;
}

.app-theme table {
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    width: 100%;
}

.app-theme table th {
    color: #33415f;
    font-size: 12px;
    letter-spacing: 0.02em;
}

.app-theme table td {
    color: #172033;
}

.app-theme table tbody tr {
    background: rgba(255, 255, 255, 0.52);
    transition: background-color 0.15s ease;
}

.app-theme table tbody tr:nth-child(even) {
    background: rgba(246, 249, 255, 0.62);
}

.app-theme table tbody tr:hover {
    background: rgba(240, 245, 255, 0.78);
}

.tickets-page {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.tickets-table th {
    font-size: 15px !important;
    padding: 12px 16px !important;
}

.tickets-table td {
    font-size: 16px !important;
    padding: 13px 16px !important;
}

.tickets-table td .text-xs,
.tickets-table td span.text-xs {
    font-size: 14px !important;
}

.users-page-title h1 {
    color: #172033;
}

.users-table-card {
    border: 1px solid rgba(255, 255, 255, 0.82) !important;
    border-left: 4px solid #6477f2 !important;
    background: rgba(255, 255, 255, 0.88) !important;
}

.users-table th,
.users-table td {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
}

.users-table thead th {
    background: rgba(235, 241, 255, 0.94);
    border-bottom: 1px solid rgba(173, 184, 220, 0.72);
}

.users-table tbody td {
    border-bottom: 1px solid rgba(199, 209, 236, 0.58);
}

.users-table tbody tr:last-child td {
    border-bottom: 0;
}

.users-table a.text-blue-600 {
    color: #5266e8 !important;
}

.app-theme .text-gray-500 {
    color: #62708d !important;
}

@media (max-width: 900px) {
    .app-nav-row {
        align-items: flex-start !important;
    }

    .app-nav-links {
        order: 3;
        width: 100%;
        gap: 8px !important;
        overflow-x: auto;
        padding: 4px 0 2px;
        scrollbar-width: thin;
    }

    .app-nav-links a {
        flex: 0 0 auto;
        border: 1px solid rgba(173, 184, 220, 0.72);
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.72);
        padding: 7px 10px;
        font-size: 13px;
        line-height: 1;
        white-space: nowrap;
    }

    .app-user-menu {
        margin-left: auto;
    }
}

@media (max-width: 768px) {
    .app-page-container {
        width: 100%;
        max-width: 100%;
        padding: 12px !important;
    }

    .app-theme h1 {
        font-size: 20px !important;
        line-height: 1.2 !important;
    }

    .app-theme h2 {
        font-size: 17px !important;
        line-height: 1.25 !important;
    }

    .app-theme .flex.items-center.justify-between,
    .app-theme .flex.items-start.justify-between {
        align-items: flex-start !important;
        gap: 10px !important;
    }

    .app-theme .grid-cols-3,
    .app-theme .grid-cols-4,
    .app-theme .grid-cols-5,
    .app-theme .grid-cols-6,
    .app-theme .grid-cols-8,
    .app-theme .grid-cols-12 {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .app-theme table {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .app-theme table th,
    .app-theme table td {
        padding: 8px 10px !important;
        white-space: nowrap;
    }

    .app-theme table td {
        vertical-align: top;
    }

    .app-theme input,
    .app-theme select,
    .app-theme textarea,
    .app-theme button {
        min-height: 40px;
        font-size: 16px;
    }

    .app-theme a.bg-blue-600,
    .app-theme button.bg-blue-600,
    .app-theme a.bg-green-600,
    .app-theme button.bg-green-600,
    .app-theme a.bg-gray-800,
    .app-theme button.bg-gray-800 {
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .reports-titlebar,
    .users-page-title {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .reports-actions {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
    }
}

@media (max-width: 520px) {
    .app-nav-inner {
        padding: 8px 10px !important;
    }

    .app-logo {
        width: 118px !important;
        height: 38px !important;
    }

    .app-public-header {
        min-height: 52px;
        padding: 8px 10px;
    }

    .app-user-menu {
        width: 100%;
        justify-content: space-between;
        gap: 10px !important;
    }

    .app-user-menu .text-right {
        text-align: left !important;
        min-width: 0;
    }

    .app-user-menu .text-sm,
    .app-user-menu .text-xs {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-theme .grid-cols-2 {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .app-theme .rounded-xl,
    .app-theme .rounded-lg {
        border-radius: 8px !important;
    }

    .app-theme .p-6,
    .app-theme .p-5,
    .app-theme .p-4 {
        padding: 12px !important;
    }

    .app-flash {
        padding: 10px 12px !important;
        font-size: 13px;
    }

    .login-compact-shell {
        min-height: auto !important;
        margin-top: -8px;
        padding-top: 0 !important;
    }

    .login-photo-panel {
        min-height: 110px !important;
        border-right: 0;
        border-bottom: 1px solid rgba(173, 184, 220, 0.5);
    }

    .reports-actions {
        grid-template-columns: 1fr;
    }

    .report-type-link {
        flex: 1 1 100%;
        white-space: normal !important;
    }
}

@media print {
    .app-theme {
        background: #fff !important;
    }
    .app-theme .bg-white,
    .app-theme nav {
        box-shadow: none !important;
        backdrop-filter: none !important;
    }
}

/* Global compact mode: keep operational screens closer to a single viewport. */
.app-theme {
    font-size: 16px;
}

.app-page-container {
    width: 100% !important;
    max-width: var(--app-max-readable-width) !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding: 10px var(--app-page-pad) !important;
}

.app-nav-inner {
    max-width: var(--app-max-readable-width) !important;
    padding: 6px var(--app-page-pad) !important;
}

.app-nav-row,
.app-user-menu {
    gap: 10px !important;
}

.app-logo {
    width: 170px !important;
    height: 50px !important;
}

.app-nav-links {
    gap: 12px !important;
}

@media (min-width: 901px) {
    .app-nav-row {
        display: grid !important;
        grid-template-columns: auto minmax(0, 1fr) auto;
        align-items: center !important;
        gap: 16px !important;
    }

    .app-nav-links {
        min-width: 0;
        justify-content: center;
        gap: clamp(7px, 0.7vw, 16px) !important;
        flex-wrap: nowrap !important;
        white-space: nowrap;
    }

    .app-nav-links a,
    .app-user-menu,
    .app-user-menu a {
        white-space: nowrap;
    }

    .app-user-menu {
        justify-self: end;
    }
}

.app-nav-links a,
.app-user-menu a {
    font-size: 14px !important;
    line-height: 1.25 !important;
}

.app-theme h1 {
    font-size: 20px !important;
    line-height: 1.15 !important;
    margin-bottom: 10px !important;
}

.app-theme h2 {
    font-size: 16px !important;
    line-height: 1.2 !important;
}

.app-theme form.bg-white,
.app-theme section.bg-white,
.app-theme div.bg-white.rounded-xl,
.app-theme div.bg-white.rounded-lg,
.app-theme .bg-white.rounded-xl,
.app-theme .bg-white.rounded-lg {
    padding: 12px !important;
    border-radius: 8px !important;
}

.app-theme .p-6 {
    padding: 12px !important;
}

.app-theme .p-5,
.app-theme .p-4 {
    padding: 10px !important;
}

.app-theme .px-6 {
    padding-left: 12px !important;
    padding-right: 12px !important;
}

.app-theme .px-4 {
    padding-left: 10px !important;
    padding-right: 10px !important;
}

.app-theme .py-4 {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
}

.app-theme .py-3 {
    padding-top: 7px !important;
    padding-bottom: 7px !important;
}

.app-theme .py-2 {
    padding-top: 6px !important;
    padding-bottom: 6px !important;
}

.app-theme .mb-8 {
    margin-bottom: 14px !important;
}

.app-theme .mb-6 {
    margin-bottom: 12px !important;
}

.app-theme .mb-5 {
    margin-bottom: 10px !important;
}

.app-theme .mb-4 {
    margin-bottom: 8px !important;
}

.app-theme .mt-6 {
    margin-top: 12px !important;
}

.app-theme .mt-4 {
    margin-top: 8px !important;
}

.app-theme .mt-3 {
    margin-top: 6px !important;
}

.app-theme .space-y-6 > :not([hidden]) ~ :not([hidden]) {
    margin-top: 12px !important;
}

.app-theme .space-y-4 > :not([hidden]) ~ :not([hidden]) {
    margin-top: 8px !important;
}

.app-theme .space-y-3 > :not([hidden]) ~ :not([hidden]) {
    margin-top: 6px !important;
}

.app-theme .gap-6 {
    gap: 12px !important;
}

.app-theme .gap-4 {
    gap: 10px !important;
}

.app-theme .gap-3 {
    gap: 8px !important;
}

.app-theme input,
.app-theme select,
.app-theme textarea {
    min-height: var(--app-control-height) !important;
    padding: 6px 9px !important;
    font-size: 13px !important;
    line-height: 1.25 !important;
}

.app-theme textarea {
    min-height: 70px !important;
}

.app-theme label {
    font-size: 12px !important;
    margin-bottom: 3px !important;
}

.app-theme button,
.app-theme a.bg-blue-600,
.app-theme a.bg-indigo-600,
.app-theme a.bg-emerald-600,
.app-theme a.bg-red-600,
.app-theme button.px-4,
.app-theme a.px-4 {
    min-height: var(--app-control-height);
    padding: 6px 10px !important;
    font-size: 12px !important;
    line-height: 1.1 !important;
    border-radius: 6px !important;
}

.app-theme .overflow-x-auto,
.app-theme .users-table-card,
.app-theme .bg-white.overflow-x-auto,
.app-theme section.overflow-hidden,
.app-theme div.overflow-hidden {
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

.app-theme .overflow-x-auto > table,
.app-theme .users-table-card > table,
.app-theme div.bg-white.rounded-xl > table,
.app-theme div.bg-white.rounded-lg > table {
    min-width: max-content;
}

.app-theme .grid {
    min-width: 0;
}

.app-theme .grid > *,
.app-theme .flex > * {
    min-width: 0;
}

.app-theme table {
    font-size: 12px !important;
}

.app-theme table th,
.app-theme table td {
    padding: 6px 8px !important;
    line-height: 1.25 !important;
}

.app-theme table th {
    font-size: 11px !important;
}

.app-theme .text-3xl {
    font-size: 22px !important;
}

.app-theme .text-2xl {
    font-size: 20px !important;
}

.app-theme .text-xl {
    font-size: 18px !important;
}

.app-theme .text-lg {
    font-size: 16px !important;
}

.app-theme .text-sm {
    font-size: 12px !important;
}

.app-theme .text-xs {
    font-size: 11px !important;
}

.login-compact-shell {
    min-height: calc(100vh - 78px) !important;
    padding-top: 4px !important;
    padding-bottom: 4px !important;
}

.login-compact-card {
    max-width: 760px !important;
}

@media (max-width: 768px) {
    .app-page-container {
        padding: 8px !important;
    }

    .app-public-header {
        min-height: 46px;
        padding: 5px 10px;
    }

    .app-logo {
        width: 150px !important;
        height: 44px !important;
    }

    .app-theme input,
    .app-theme select,
    .app-theme textarea {
        font-size: 16px !important;
    }
}

@media (max-width: 640px) {
    :root {
        --app-page-pad: 8px;
        --app-control-height: 42px;
    }

    body {
        background-attachment: scroll !important;
    }

    .app-theme {
        background-attachment: scroll !important;
        background:
            linear-gradient(135deg, #edf4ff 0%, #eef1ff 52%, #f5f0ff 100%) !important;
    }

    .app-theme nav,
    .app-theme .bg-white {
        backdrop-filter: none;
    }

    .app-page-container {
        padding-top: 8px !important;
        padding-bottom: 8px !important;
    }

    #app-alert-stack {
        left: 8px !important;
        right: 8px !important;
        top: 8px !important;
        width: auto !important;
    }

    .app-theme .flex.items-center.justify-between,
    .app-theme .flex.items-start.justify-between,
    .app-theme .users-page-title,
    .app-theme .reports-titlebar {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .app-theme .flex.items-center.justify-between > a,
    .app-theme .flex.items-start.justify-between > a,
    .app-theme .users-page-title > a,
    .app-theme .reports-titlebar a,
    .app-theme .reports-titlebar button {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    .app-theme .overflow-x-auto,
    .app-theme .users-table-card,
    .app-theme .bg-white.overflow-x-auto {
        border-radius: 8px !important;
    }

    .app-theme table {
        min-width: 680px;
    }

    .tickets-table td,
    .tickets-table th {
        white-space: normal !important;
    }
}

@media (min-width: 769px) and (max-width: 1180px) {
    :root {
        --app-page-pad: 12px;
        --app-control-height: 38px;
    }

    .app-nav-links {
        gap: 10px !important;
    }

    .app-nav-links a,
    .app-user-menu a {
        font-size: 13px !important;
    }

    .app-theme .grid-cols-4,
    .app-theme .grid-cols-5,
    .app-theme .grid-cols-6,
    .app-theme .grid-cols-8,
    .app-theme .grid-cols-12 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (min-width: 1600px) {
    :root {
        --app-page-pad: clamp(18px, 1.2vw, 32px);
        --app-control-height: 38px;
    }

    .app-theme {
        font-size: 17px;
    }

    .app-theme table {
        font-size: 13px !important;
    }

    .app-theme table th {
        font-size: 12px !important;
    }
}

@media (min-width: 2200px) {
    :root {
        --app-max-readable-width: var(--app-wide-readable-width);
        --app-page-pad: 34px;
        --app-control-height: 42px;
    }

    .app-theme {
        font-size: 18px;
    }

    .app-logo {
        width: 210px !important;
        height: 62px !important;
    }

    .app-nav-links a,
    .app-user-menu a {
        font-size: 16px !important;
    }

    .app-theme h1 {
        font-size: 28px !important;
    }

    .app-theme h2 {
        font-size: 21px !important;
    }

    .app-theme .text-sm {
        font-size: 14px !important;
    }

    .app-theme .text-xs {
        font-size: 13px !important;
    }

    .app-theme input,
    .app-theme select,
    .app-theme textarea,
    .app-theme table {
        font-size: 15px !important;
    }
}

@media (min-width: 3200px) {
    :root {
        --app-max-readable-width: 2800px;
        --app-page-pad: 48px;
        --app-control-height: 48px;
    }

    .app-theme {
        font-size: 22px;
    }

    .app-theme h1 {
        font-size: 36px !important;
    }

    .app-theme h2 {
        font-size: 28px !important;
    }

    .app-theme input,
    .app-theme select,
    .app-theme textarea,
    .app-theme button,
    .app-theme a.bg-blue-600,
    .app-theme a.bg-green-600,
    .app-theme table {
        font-size: 18px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
