@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Inter:wght@400;500;600&display=swap');

@tailwind base;
@tailwind components;
@tailwind utilities;

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

    body {
        @apply font-sans text-surface-800 antialiased;
    }

    h1, h2, h3, h4, h5, h6 {
        @apply font-display tracking-tight;
    }

    /* ── Form element normalization (no @tailwindcss/forms plugin needed) ── */
    [type='text'], [type='email'], [type='password'], [type='number'],
    [type='tel'], [type='url'], [type='search'], [type='date'], textarea {
        -webkit-appearance: none;
        appearance: none;
    }

    select {
        -webkit-appearance: none;
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%23a1a1aa' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 0.625rem center;
        background-size: 1.25em 1.25em;
    }

    [type='checkbox'], [type='radio'] {
        -webkit-appearance: none;
        appearance: none;
        display: inline-block;
        vertical-align: middle;
        flex-shrink: 0;
        width: 1rem;
        height: 1rem;
        background-color: #ffffff;
        border-width: 1.5px;
        border-style: solid;
        border-color: #d4d4d8;
        color: #00629b;
        transition: background-color 0.1s ease, border-color 0.1s ease;
    }
    [type='checkbox'] { border-radius: 0.25rem; }
    [type='radio']    { border-radius: 9999px; }

    [type='checkbox']:checked {
        background-color: currentColor;
        border-color: currentColor;
        background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3E%3C/svg%3E");
        background-size: 100% 100%;
        background-position: center;
        background-repeat: no-repeat;
    }
    [type='radio']:checked {
        background-color: currentColor;
        border-color: currentColor;
        background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='8' cy='8' r='3'/%3E%3C/svg%3E");
        background-size: 100% 100%;
        background-position: center;
        background-repeat: no-repeat;
    }
    [type='checkbox']:focus, [type='radio']:focus {
        outline: 2px solid #1487cc;
        outline-offset: 2px;
        box-shadow: 0 0 0 4px rgba(20, 135, 204, 0.12);
    }
    [type='checkbox']:disabled, [type='radio']:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    /* Consistent interaction feedback for standalone buttons across the app. */
    button:not([role='switch']) {
        transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease,
                    box-shadow 180ms ease, filter 180ms ease, transform 180ms ease;
    }
    button:not([role='switch']):not(:disabled):hover {
        filter: brightness(1.04);
        transform: translateY(-1px);
    }
    button:not([role='switch']):not(:disabled):active {
        filter: brightness(0.98);
        transform: translateY(0) scale(0.97);
    }
    button:not([role='switch']):focus-visible {
        outline: 2px solid rgb(20 135 204 / 0.55);
        outline-offset: 2px;
    }

    @media (prefers-reduced-motion: reduce) {
        button, .btn, .inline-icon-button {
            transition-duration: 0.01ms !important;
        }

        button, .btn, .inline-icon-button,
        button:hover, .btn:hover, .inline-icon-button:hover,
        button:active, .btn:active, .inline-icon-button:active {
            transform: none !important;
        }
    }
}

@layer components {

    /* ─── Buttons ─────────────────────────────────────────────────────── */
    .btn {
        @apply inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl font-medium text-sm
               transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2
               disabled:opacity-50 disabled:cursor-not-allowed;
        transform: translateY(0) scale(1);
        will-change: transform, box-shadow;
    }
    .btn:not(:disabled):hover {
        transform: translateY(-2px) scale(1.01);
    }
    .btn:not(:disabled):active {
        transform: translateY(0) scale(0.97);
    }
    .btn-primary {
        @apply btn bg-primary-600 text-white shadow-sm
               hover:bg-primary-700 hover:shadow-glow
               focus:ring-primary-500;
    }
    .btn-secondary {
        @apply btn bg-white text-surface-700 border border-surface-200 shadow-sm
               hover:bg-surface-50 hover:border-surface-300
               focus:ring-surface-300;
    }
    .btn-danger {
        @apply btn bg-red-50 text-red-600 border border-red-100
               hover:bg-red-600 hover:text-white hover:border-transparent
               focus:ring-red-500;
    }
    .btn-ghost {
        @apply btn bg-transparent text-surface-600
               hover:bg-surface-100 hover:text-surface-900
               focus:ring-surface-300;
    }

    /* ─── Form Inputs ─────────────────────────────────────────────────── */
    .form-input {
        @apply block w-full rounded-xl border border-surface-200 bg-surface-50/50 shadow-sm
               py-2 px-3
               focus:border-primary-400 focus:ring-4 focus:ring-primary-500/10 focus:bg-white
               sm:text-sm transition-all duration-200 placeholder:text-surface-400
               disabled:opacity-60 disabled:cursor-not-allowed disabled:bg-surface-100;
    }
    /* Extra right padding for the custom dropdown arrow */
    select.form-input {
        @apply pr-10;
    }
    .form-input-error {
        @apply border-red-300 bg-red-50/30 focus:border-red-400 focus:ring-red-500/10;
    }

    /* Approved form treatment: consistent controls and one clean focus border. */
    .enhanced-form .form-input {
        min-height: 2.75rem;
        background-color: #ffffff;
    }

    .enhanced-form input.form-input:not([type='hidden']):not([type='checkbox']):not([type='radio']),
    .enhanced-form textarea.form-input {
        padding-left: 2.75rem;
        background-repeat: no-repeat;
        background-position: left 0.875rem center;
        background-size: 1rem 1rem;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M9 6V4h6v2m-9 0h12a2 2 0 012 2v9a2 2 0 01-2 2H6a2 2 0 01-2-2V8a2 2 0 012-2zm-2 6h16'/%3E%3C/svg%3E");
    }

    .enhanced-form textarea.form-input {
        background-position: left 0.875rem top 0.875rem;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M12 21s7-5.1 7-11a7 7 0 10-14 0c0 5.9 7 11 7 11zm0-8a3 3 0 100-6 3 3 0 000 6z'/%3E%3C/svg%3E");
    }

    .enhanced-form input[type='email'].form-input {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M3 6l9 6 9-6M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z'/%3E%3C/svg%3E") !important;
    }

    .enhanced-form input[type='tel'].form-input {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M5 4h4l2 5-3 2a16 16 0 005 5l2-3 5 2v4a2 2 0 01-2 2C10 21 3 14 3 6a2 2 0 012-2z'/%3E%3C/svg%3E") !important;
    }

    .enhanced-form input[type='password'].form-input {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M8 11V8a4 4 0 118 0v3m-9 0h10a1 1 0 011 1v8H6v-8a1 1 0 011-1z'/%3E%3C/svg%3E") !important;
    }

    /* Password fields with a show/hide toggle get their `type` flipped between
       'password' and 'text' by Alpine, which drops the type-based icon above.
       Pin the lock icon by field name so it survives the toggle. */
    .enhanced-form input[name='password'].form-input,
    .enhanced-form input[name='current_password'].form-input,
    .enhanced-form input[name='new_password'].form-input,
    .enhanced-form input[name='new_password_confirmation'].form-input,
    .enhanced-form input[name='password_confirmation'].form-input {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M8 11V8a4 4 0 118 0v3m-9 0h10a1 1 0 011 1v8H6v-8a1 1 0 011-1z'/%3E%3C/svg%3E") !important;
    }

    .enhanced-form input[type='date'].form-input {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M7 3v3m10-3v3M4 9h16M5 5h14a1 1 0 011 1v14H4V6a1 1 0 011-1zm3 8h3m2 0h3m-8 4h3'/%3E%3C/svg%3E") !important;
    }

    .enhanced-form input[name='full_name'].form-input {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M12 12a4 4 0 100-8 4 4 0 000 8zm7 9a7 7 0 00-14 0'/%3E%3C/svg%3E") !important;
    }

    .enhanced-form input[name='title'].form-input {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M7 3h7l5 5v13H7a2 2 0 01-2-2V5a2 2 0 012-2zm7 0v5h5M9 13h6m-6 4h6'/%3E%3C/svg%3E") !important;
    }

    .enhanced-form input[name='version'].form-input {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M7 7h10v10H7V7zm-3 3v10h10m-4-16h10v10'/%3E%3C/svg%3E") !important;
    }

    .enhanced-form textarea[name='description'].form-input {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M5 4h14v16H5V4zm4 4h6m-6 4h6m-6 4h4'/%3E%3C/svg%3E") !important;
    }

    .form-icon-search {
        padding-left: 2.5rem;
        background-repeat: no-repeat;
        background-position: left 0.75rem center;
        background-size: 1rem 1rem;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M21 21l-5-5m2-6a8 8 0 11-16 0 8 8 0 0116 0z'/%3E%3C/svg%3E");
    }

    .form-icon-date,
    .form-icon-note,
    .form-icon-role,
    .form-icon-folder,
    .form-icon-office {
        padding-left: 2.75rem;
        background-repeat: no-repeat;
        background-position: left 0.875rem center;
        background-size: 1rem 1rem;
    }

    textarea.form-icon-note {
        background-position: left 0.875rem top 0.875rem;
    }

    .form-icon-date {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M7 3v3m10-3v3M4 9h16M5 5h14a1 1 0 011 1v14H4V6a1 1 0 011-1zm3 8h3m2 0h3m-8 4h3'/%3E%3C/svg%3E") !important;
    }

    .form-icon-note {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M5 4h14v16H5V4zm4 4h6m-6 4h6m-6 4h4'/%3E%3C/svg%3E") !important;
    }

    .form-icon-role {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M12 3l7 3v5c0 4.6-2.9 8.7-7 10-4.1-1.3-7-5.4-7-10V6l7-3zm-3 9l2 2 4-4'/%3E%3C/svg%3E") !important;
    }

    .form-icon-folder {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M3 7a2 2 0 012-2h4l2 2h8a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2V7z'/%3E%3C/svg%3E") !important;
    }

    .form-icon-office {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2M5 21H3m6-14h1m-1 4h1m4-4h1m-1 4h1M9 21v-5h6v5'/%3E%3C/svg%3E") !important;
    }

    input.searchable-select-search {
        padding-left: 2.5rem;
        background-repeat: no-repeat;
        background-position: left 0.75rem center;
        background-size: 1rem 1rem;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M21 21l-5-5m2-6a8 8 0 11-16 0 8 8 0 0116 0z'/%3E%3C/svg%3E") !important;
    }

    .enhanced-form .form-label {
        @apply font-semibold text-surface-700;
    }

    .enhanced-form .form-input:focus,
    .enhanced-form .form-input:focus-visible,
    .user-form-card .form-input:focus,
    .user-form-card .form-input:focus-visible {
        border-color: #1487cc;
        outline: none;
        box-shadow: none;
    }

    .enhanced-form .card > .section-label:first-child {
        @apply border-b border-surface-100 bg-gradient-to-r from-surface-50/80 to-white
               text-sm font-bold normal-case tracking-normal text-surface-900;
        margin: -1.5rem -1.5rem 1.25rem;
        padding: 1rem 1.5rem;
    }

    .enhanced-form .form-actions {
        @apply flex flex-wrap items-center justify-end gap-3 border-t border-surface-100
               bg-surface-50/70 px-6 py-4;
    }

    .enhanced-form .form-actions-attached {
        margin-right: -1.5rem;
        margin-bottom: -1.5rem;
        margin-left: -1.5rem;
        border-radius: 0 0 1rem 1rem;
    }
    .form-label {
        @apply block text-sm font-medium text-surface-700 mb-1.5;
    }

    /* ─── Sidebar ─────────────────────────────────────────────────────── */
    .sidebar-link {
        @apply flex items-center gap-3 px-3 py-2.5 rounded-xl text-sm font-medium
               transition-all duration-150 text-surface-500
               hover:bg-surface-100 hover:text-surface-900;
    }
    .sidebar-link-active {
        @apply sidebar-link bg-primary-50 text-primary-700
               hover:bg-primary-100 hover:text-primary-800
               shadow-sm relative;
    }
    .sidebar-link-active::before {
        content: '';
        @apply absolute left-0 top-1/2 -translate-y-1/2 w-0.5 h-5 bg-primary-600 rounded-r-full;
    }

    /* ─── Tables ──────────────────────────────────────────────────────── */
    .table-th {
        @apply px-6 py-3.5 text-left text-xs font-semibold text-surface-400
               uppercase tracking-wider bg-surface-50/80;
    }
    .table-td {
        @apply px-6 py-4 whitespace-nowrap text-sm text-surface-700;
    }
    .table-row-hover {
        @apply hover:bg-surface-50/60 transition-colors duration-150;
    }

    /* ─── Cards ───────────────────────────────────────────────────────── */
    .card {
        @apply bg-white rounded-2xl border border-surface-100 shadow-soft;
    }
    .card-hover {
        @apply card hover:shadow-soft-lg transition-shadow duration-300;
    }
    .stat-card {
        @apply card p-6 flex items-center gap-4
               hover:-translate-y-0.5 transition-transform duration-300;
    }

    /* ─── Page chrome ─────────────────────────────────────────────────── */
    .page-header {
        @apply flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-8;
    }
    .section-label {
        @apply block text-xs font-semibold text-surface-400 uppercase tracking-wider mb-3;
    }
    .page-title {
        @apply font-display text-2xl font-bold text-surface-900 tracking-tight;
    }
    .page-subtitle {
        @apply text-sm text-surface-500 mt-0.5;
    }

    /* ─── Badge base (extended by badge component) ────────────────────── */
    .badge {
        @apply inline-flex items-center gap-1.5 rounded-full px-2.5 py-1
               text-xs font-semibold;
    }

    .panel-header {
        @apply flex items-start justify-between gap-4 border-b border-surface-100 px-5 py-4 sm:px-6;
    }

    .panel-title {
        @apply text-sm font-semibold text-surface-900;
    }

    .panel-subtitle {
        @apply mt-1 text-xs text-surface-400;
    }

    .empty-state {
        @apply flex flex-col items-center justify-center px-6 py-16 text-center;
    }

    .empty-state-icon {
        @apply mb-4 flex h-14 w-14 items-center justify-center rounded-2xl bg-surface-100 text-surface-400;
    }

    .summary-grid-3,
    .summary-grid-4,
    .summary-grid-5 {
        display: grid;
        gap: 1rem;
    }

    .summary-grid-3 {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }

    .summary-grid-4 {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }

    .summary-grid-5 {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }

    .split-panel {
        display: grid;
        gap: 1.25rem;
        grid-template-columns: minmax(0, 1fr);
    }

    .inline-icon-button {
        @apply inline-flex h-8 w-8 items-center justify-center rounded-lg transition-all duration-200
               focus:outline-none focus:ring-2 focus:ring-primary-500/30 focus:ring-offset-1
               disabled:cursor-not-allowed disabled:opacity-50;
        transform: translateY(0) scale(1);
    }

    .inline-icon-button:not(:disabled):hover {
        transform: translateY(-1px) scale(1.08);
        box-shadow: 0 5px 12px -5px rgb(15 23 42 / 0.28);
    }

    .inline-icon-button:not(:disabled):active {
        transform: translateY(0) scale(0.92);
    }

    .inline-icon-button-neutral {
        @apply inline-icon-button bg-surface-100 text-surface-500 hover:bg-surface-200 hover:text-surface-700;
    }

    .inline-icon-button-primary {
        @apply inline-icon-button bg-primary-50 text-primary-600 hover:bg-primary-100;
    }

    .inline-icon-button-danger {
        @apply inline-icon-button bg-red-50 text-red-600 hover:bg-red-100;
    }

    .quick-link {
        @apply flex items-center gap-3 rounded-xl bg-surface-50 px-3 py-2.5 text-sm font-semibold text-surface-900 transition-colors hover:bg-surface-100;
    }

    .quick-link-icon {
        @apply flex h-8 w-8 shrink-0 items-center justify-center rounded-lg;
    }

    .mini-stat {
        @apply rounded-xl border border-white/15 bg-white/10 px-4 py-3 backdrop-blur-sm;
    }

    .mini-stat-value {
        @apply text-2xl font-extrabold leading-none text-white;
    }

    .mini-stat-label {
        @apply mt-1 text-xs font-medium text-white/65;
    }

    .metric-tile {
        @apply card flex items-start gap-3 p-5;
    }

    .metric-tile-compact {
        @apply card flex items-center gap-3 p-4;
    }

    .metric-icon {
        @apply flex h-11 w-11 shrink-0 items-center justify-center rounded-xl;
    }

    .metric-icon-sm {
        @apply flex h-9 w-9 shrink-0 items-center justify-center rounded-lg;
    }

    .detail-stat {
        @apply flex items-center gap-2 rounded-xl border border-surface-100 bg-surface-50 px-3 py-2.5;
    }

    .detail-stat-icon {
        @apply flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-100 text-surface-400;
    }

    .detail-stat-value {
        @apply text-base font-extrabold leading-none text-surface-900;
    }

    .detail-stat-label {
        @apply mt-0.5 text-[10px] text-surface-400;
    }

    .document-type-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
        gap: 0.75rem;
        margin-top: 0.5rem;
    }

    .document-type-option {
        display: block;
        cursor: pointer;
    }

    .document-type-option--controlled_documents {
        --type-color: #2563eb;
        --type-soft: #eff6ff;
        --type-soft-strong: #dbeafe;
        --type-border: #bfdbfe;
        --type-shadow: rgba(37, 99, 235, 0.18);
        --type-card-bg: #f6faff;
        --type-orb-bg: #e5effe;
        --type-checked-border: #c2d3f9;
        --type-icon-border: #e5ecfd;
        --type-title: #152b5c;
        --type-desc: #385ba4;
        --type-ring: #f1f7ff;
    }

    .document-type-option--records {
        --type-color: #059669;
        --type-soft: #ecfdf5;
        --type-soft-strong: #d1fae5;
        --type-border: #a7f3d0;
        --type-shadow: rgba(5, 150, 105, 0.18);
        --type-card-bg: #f5fefa;
        --type-orb-bg: #defbec;
        --type-checked-border: #b9e1d5;
        --type-icon-border: #e1f2ed;
        --type-title: #0c383a;
        --type-desc: #297269;
        --type-ring: #eefdf6;
    }

    .document-type-option--bulletins {
        --type-color: #d97706;
        --type-soft: #fffbeb;
        --type-soft-strong: #fde68a;
        --type-border: #fde68a;
        --type-shadow: rgba(217, 119, 6, 0.18);
        --type-card-bg: #fffcf4;
        --type-orb-bg: #feedab;
        --type-checked-border: #f4d8b9;
        --type-icon-border: #faeee1;
        --type-title: #433021;
        --type-desc: #89643c;
        --type-ring: #fffbed;
    }

    .document-type-card {
        position: relative;
        display: flex;
        min-height: 104px;
        align-items: flex-start;
        gap: 0.75rem;
        overflow: hidden;
        border: 1.5px solid #e2e8f0;
        border-radius: 0.875rem;
        background: linear-gradient(180deg, var(--type-card-bg) 0%, #ffffff 100%);
        padding: 0.875rem 0.95rem 0.875rem 0.875rem;
        box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
        transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, transform 0.18s ease;
    }

    .document-type-card::after {
        content: "";
        position: absolute;
        top: -28px;
        right: -18px;
        width: 92px;
        height: 92px;
        border-radius: 999px;
        background: radial-gradient(circle, var(--type-orb-bg) 0%, transparent 72%);
        pointer-events: none;
        opacity: 0.9;
    }

    .document-type-option:hover .document-type-card {
        border-color: var(--type-border);
        box-shadow: 0 12px 26px var(--type-shadow);
        transform: translateY(-1px);
    }

    .document-type-option input:checked + .document-type-card {
        border-color: var(--type-checked-border);
        background: linear-gradient(180deg, var(--type-soft-strong) 0%, #ffffff 100%);
        box-shadow: 0 14px 28px var(--type-shadow), 0 0 0 3px var(--type-ring);
    }

    .document-type-accent {
        position: absolute;
        inset: 0 auto 0 0;
        width: 4px;
        background: var(--type-color);
    }

    .document-type-icon {
        display: inline-flex;
        width: 2.5rem;
        height: 2.5rem;
        flex-shrink: 0;
        align-items: center;
        justify-content: center;
        border-radius: 0.75rem;
        border: 1px solid var(--type-icon-border);
        background: linear-gradient(180deg, var(--type-soft-strong) 0%, var(--type-soft) 100%);
        color: var(--type-color);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
    }

    .document-type-copy {
        min-width: 0;
        flex: 1;
        padding-top: 0.0625rem;
    }

    .document-type-title {
        display: block;
        padding-right: 1.75rem;
        color: var(--type-title);
        font-size: 0.8125rem;
        font-weight: 800;
        line-height: 1.25;
    }

    .document-type-description {
        display: block;
        margin-top: 0.3125rem;
        color: #64748b;
        font-size: 0.6875rem;
        line-height: 1.45;
    }

    .document-type-check {
        position: absolute;
        top: 0.875rem;
        right: 0.875rem;
        display: inline-flex;
        width: 1.25rem;
        height: 1.25rem;
        align-items: center;
        justify-content: center;
        border: 1.5px solid #cbd5e1;
        border-radius: 999px;
        background: #ffffff;
        color: #ffffff;
        transition: border-color 0.18s ease, background 0.18s ease;
    }

    .document-type-option input:checked + .document-type-card .document-type-check {
        border-color: var(--type-color);
        background: var(--type-color);
    }

    .document-type-option input:checked + .document-type-card .document-type-description {
        color: var(--type-desc);
    }

    .folders-layout {
        display: grid;
        grid-template-columns: minmax(0, 3fr) minmax(280px, 1fr);
        gap: 24px;
        align-items: start;
    }

    .folders-grid {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        align-items: start;
        gap: 28px 20px;
        width: 100%;
    }

    .folder-card {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        width: 100%;
        max-width: 150px;
        min-height: 150px;
        margin: 0 auto;
        padding: 16px 10px 14px;
        border: none;
        border-radius: 14px;
        cursor: pointer;
        text-align: center;
        transition: background 0.12s;
    }

    .folder-card__icon {
        position: relative;
        width: 104px;
        height: 82px;
        margin: 0 auto 12px;
        flex-shrink: 0;
    }

    .folder-card__title {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        width: 100%;
        min-height: 2.8em;
        margin: 0;
        color: #1e293b;
        font-size: 13px;
        font-weight: 600;
        line-height: 1.4;
        text-align: center;
        word-break: break-word;
    }

    .folder-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 0 20px 20px;
    }

    .folder-action-primary,
    .folder-action-secondary,
    .folder-action-muted,
    .folder-action-danger {
        display: inline-flex;
        width: 100%;
        align-items: center;
        justify-content: center;
        gap: 8px;
        box-sizing: border-box;
        text-decoration: none;
        transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
    }

    .folder-action-primary {
        border: 0;
        border-radius: 14px;
        padding: 13px 16px;
        color: #ffffff;
        font-size: 13px;
        font-weight: 800;
        letter-spacing: 0.01em;
        box-shadow: 0 12px 24px rgba(15, 23, 42, 0.14);
    }

    .folder-action-secondary {
        border-radius: 14px;
        padding: 12px 16px;
        font-size: 13px;
        font-weight: 700;
        backdrop-filter: blur(8px);
    }

    .folder-action-row {
        display: flex;
        gap: 8px;
        margin-top: 2px;
    }

    .folder-action-muted,
    .folder-action-danger {
        flex: 1;
        border-radius: 12px;
        padding: 10px 12px;
        font-size: 13px;
        font-weight: 700;
    }

    .folder-action-muted {
        border: 1px solid #e2e8f0;
        background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
        color: #475569;
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
    }

    .folder-action-danger {
        border: 1px solid #fecaca;
        background: linear-gradient(180deg, #fff5f5 0%, #feefef 100%);
        color: #dc2626;
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
        cursor: pointer;
    }

    .folder-action-primary:hover,
    .folder-action-secondary:hover,
    .folder-action-muted:hover,
    .folder-action-danger:hover {
        transform: translateY(-1px);
    }

    .folder-status-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 7px 12px;
        border-radius: 999px;
        font-size: 11px;
        font-weight: 700;
        line-height: 1;
        vertical-align: top;
        white-space: nowrap;
    }

    .folder-status-badge--active {
        background: #ddf8ea;
        color: #0f7b57;
    }

    .folder-status-badge--inactive {
        background: #eef2f7;
        color: #64748b;
    }

    .folder-status-badge__dot {
        display: inline-block;
        width: 8px;
        height: 8px;
        flex-shrink: 0;
        border-radius: 50%;
    }

    .folder-status-badge__dot--active {
        background: #10b981;
    }

    .folder-status-badge__dot--inactive {
        background: #94a3b8;
    }

    /* ── File Browser ── */

    .drive-grid {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 20px;
    }

    .drive-card {
        position: relative;
        display: flex;
        flex-direction: column;
        gap: 18px;
        border-radius: 20px;
        border-width: 1.5px;
        border-style: solid;
        padding: 28px 24px;
        cursor: pointer;
        text-align: left;
        transition: box-shadow 0.15s ease, transform 0.15s ease;
    }

    .drive-card:hover {
        box-shadow: 0 10px 28px -6px rgba(0, 0, 0, 0.12);
        transform: translateY(-2px);
    }

    .drive-card__folder {
        width: 80px;
        height: 62px;
        flex-shrink: 0;
    }

    .drive-card__title {
        font-size: 1.0625rem;
        font-weight: 700;
        line-height: 1.3;
        margin: 0 0 4px;
    }

    .drive-card__desc {
        font-size: 0.8125rem;
        line-height: 1.5;
        margin: 0;
        opacity: 0.65;
    }

    .drive-card__stats {
        display: flex;
        gap: 20px;
        margin-top: auto;
    }

    .drive-stat {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .drive-stat__value {
        font-size: 1.375rem;
        font-weight: 800;
        line-height: 1;
    }

    .drive-stat__label {
        font-size: 0.6875rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        opacity: 0.55;
    }

    .file-browser-grid {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        align-items: start;
        gap: 28px 20px;
        width: 100%;
    }

    .file-card {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        width: 100%;
        max-width: 150px;
        min-height: 150px;
        margin: 0 auto;
        padding: 16px 10px 14px;
        border: none;
        border-radius: 14px;
        cursor: pointer;
        text-align: center;
        background: transparent;
        transition: background 0.12s;
    }

    .file-card__icon {
        position: relative;
        width: 60px;
        height: 88px;
        margin: 0 auto 6px;
        flex-shrink: 0;
    }

    .file-card__svg {
        width: 60px;
        height: 72px;
        filter: drop-shadow(0 2px 4px rgba(0,0,0,0.10));
    }

    .file-card__title {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        width: 100%;
        margin: 0;
        color: #1e293b;
        font-size: 13px;
        font-weight: 600;
        line-height: 1.4;
        text-align: center;
        word-break: break-word;
    }

    .file-card__meta {
        margin-top: 4px;
        font-size: 12px;
        color: #334155;
        font-weight: 700;
        text-align: center;
        line-height: 1.3;
    }
}

@media (max-width: 1279px) {
    .folders-layout {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 640px) {
    .summary-grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .summary-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .summary-grid-5 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .summary-grid-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .summary-grid-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .summary-grid-5 {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }

    .split-panel {
        grid-template-columns: minmax(0, 1fr) 320px;
    }
}

@media (max-width: 1023px) {
    .folders-grid,
    .file-browser-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .drive-grid {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }
}

@media (min-width: 640px) and (max-width: 1023px) {
    .drive-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    .folders-grid,
    .file-browser-grid {
        grid-template-columns: repeat(2, minmax(0, 130px));
    }
}

@media (max-width: 479px) {
    .folders-grid,
    .file-browser-grid {
        grid-template-columns: minmax(0, 130px);
    }
}
