/* ============================================================
   Desta Webapp - Main CSS
   ============================================================ */

:root {
    --accent: #ffa400;
    --accent-dark: #e69300;
    --accent-light: #fff3d6;
    --dark: #1a1a2e;
    --dark-2: #16213e;
    --dark-3: #0f3460;
    --text-primary: #1a1a2e;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --bg: #f5f6fa;
    --bg-card: #ffffff;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --sidebar-width: 250px;
    --header-height: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
    --shadow-md: 0 8px 30px rgba(0,0,0,0.12);
    --transition: 0.2s ease;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg);
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ============================================================
   Layout
   ============================================================ */
.desta-layout {
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--dark);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
    transition: width 0.2s ease;
}

/* Keyboard shortcut tooltip */
.sidebar-nav-item[data-shortcut]::after {
    content: attr(data-shortcut);
    margin-left: auto;
    font-size: 10px;
    color: rgba(255,255,255,0.2);
    font-weight: 600;
    letter-spacing: 1px;
    opacity: 0;
    transition: opacity 0.15s;
}

.sidebar-nav-item[data-shortcut]:hover::after {
    opacity: 1;
}

.sidebar-logo {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: auto;
}

.sidebar-logo-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    color: var(--dark);
}

.sidebar-logo-text {
    font-size: 18px;
    font-weight: 700;
    color: white;
    letter-spacing: -0.3px;
}

.sidebar-logo-text span {
    color: var(--accent);
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
}

.sidebar-quick-create {
    padding: 12px 12px 4px;
}

.sidebar-quick-create-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    background: var(--accent);
    color: var(--dark);
    font-size: 13px;
    font-weight: 700;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.sidebar-quick-create-btn:hover {
    background: var(--accent-dark);
    color: var(--dark);
    box-shadow: 0 2px 8px rgba(255, 164, 0, 0.3);
}

.sidebar-section-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.35);
    padding: 16px 12px 4px;
    margin-top: 4px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-section-label:first-child {
    border-top: none;
    margin-top: 0;
}

.sidebar-section-toggle {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

.sidebar-section-toggle:hover {
    color: rgba(255,255,255,0.5);
}

.section-chevron {
    transition: transform 0.2s;
    opacity: 0.5;
}

.section-chevron.collapsed {
    transform: rotate(-90deg);
}

.sidebar-section-items {
    overflow: hidden;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 8px 12px;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: rgba(255,255,255,0.6);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
    cursor: pointer;
}

.sidebar-nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.9);
}

.sidebar-nav-item.active {
    background: rgba(255, 164, 0, 0.12);
    color: var(--accent);
    border-left: 3px solid var(--accent);
    padding-left: 9px;
}

.sidebar-nav-item.active .nav-icon {
    color: var(--accent);
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.8;
}

.sidebar-nav-item.active .nav-icon {
    opacity: 1;
}

.nav-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: var(--dark);
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    line-height: 16px;
    flex-shrink: 0;
}

.nav-badge.subtle {
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.6);
}

.nav-badge.alert {
    background: rgba(239, 68, 68, 0.18);
    color: #fca5a5;
}

/* ── Compact sidebar mode ──────────────────────────────── */
.sidebar.compact {
    width: 56px;
}

.sidebar.compact .sidebar-logo-text,
.sidebar.compact .nav-label,
.sidebar.compact .nav-badge,
.sidebar.compact .sidebar-section-label,
.sidebar.compact .sidebar-quick-create-btn span,
.sidebar.compact .sidebar-divider {
    display: none;
}

.sidebar.compact .sidebar-logo {
    padding: 16px 10px;
    justify-content: center;
}

.sidebar.compact .sidebar-quick-create {
    padding: 8px 8px 4px;
}

.sidebar.compact .sidebar-quick-create-btn {
    padding: 10px;
    font-size: 0;
}

.sidebar.compact .sidebar-quick-create-btn svg {
    width: 20px;
    height: 20px;
}

.sidebar.compact .sidebar-nav {
    padding: 8px 6px;
}

.sidebar.compact .sidebar-nav-item {
    justify-content: center;
    padding: 10px;
    border-radius: 8px;
}

.sidebar.compact .sidebar-section-items {
    display: block !important;
}

.sidebar.compact .sidebar-footer {
    padding: 8px 6px;
}

.sidebar.compact .sidebar-footer .sidebar-nav-item {
    justify-content: center;
}

.sidebar.compact + .main-wrapper {
    margin-left: 56px;
}

.sidebar-compact-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    margin: 4px 12px;
    border-radius: 6px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.3);
    cursor: pointer;
    transition: all 0.15s;
}

.sidebar-compact-toggle:hover {
    color: rgba(255,255,255,0.6);
    background: rgba(255,255,255,0.06);
}

.sidebar.compact .sidebar-compact-toggle {
    margin: 4px 6px;
}

.sidebar-footer {
    padding: 12px 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* ============================================================
   Main Content
   ============================================================ */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.2s ease;
}

/* ============================================================
   Header
   ============================================================ */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Client Context Banner */
.client-context-banner {
    background: #eff6ff;
    border-bottom: 2px solid #3b82f6;
    padding: 0 24px;
    position: sticky;
    top: var(--header-height);
    z-index: 49;
}

.client-context-banner-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    gap: 12px;
}

.client-context-banner-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #1e40af;
    font-size: 13px;
    font-weight: 500;
    min-width: 0;
}

.client-context-banner-info svg {
    flex-shrink: 0;
    stroke: #3b82f6;
}

.client-context-banner-label {
    color: #3b82f6;
    font-weight: 600;
    white-space: nowrap;
}

.client-context-banner-name {
    font-weight: 700;
    color: #1e3a5f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.client-context-banner-nip {
    color: #6b7fa8;
    font-size: 12px;
    font-weight: 400;
    white-space: nowrap;
    padding-left: 8px;
    border-left: 1px solid #bfdbfe;
}

.client-context-banner-exit {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: white;
    color: #3b82f6;
    border: 1px solid #93c5fd;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
}

.client-context-banner-exit:hover {
    background: #dbeafe;
    border-color: #3b82f6;
}

/* KSeF Badge */
.ksef-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.ksef-badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.ksef-badge.connected {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
}

.ksef-badge.connected .ksef-badge-dot {
    background: #22c55e;
}

.ksef-badge.disconnected {
    background: rgba(107, 114, 128, 0.12);
    color: #6b7280;
}

.ksef-badge.disconnected .ksef-badge-dot {
    background: #9ca3af;
}

/* Notification bell */
.notification-bell {
    position: relative;
}

.notification-bell-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.notification-bell-btn:hover {
    background: var(--border-light);
    color: var(--text-primary);
}

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.notification-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 380px;
    max-height: 480px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow: hidden;
}

.notification-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
}

.notification-dropdown-header h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.notification-mark-all {
    background: none;
    border: none;
    font-size: 12px;
    color: var(--accent);
    cursor: pointer;
    font-weight: 500;
    padding: 0;
}

.notification-mark-all:hover {
    color: #4338ca;
}

.notification-dropdown-body {
    overflow-y: auto;
    flex: 1;
    max-height: 360px;
}

.notification-item {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.notification-item:hover {
    background: #f8fafc;
}

.notification-item.unread {
    background: #eff6ff;
}

.notification-item.unread:hover {
    background: #dbeafe;
}

.notification-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.notification-item-icon.type-ksef_incoming {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
}

.notification-item-icon.type-admin_custom,
.notification-item-icon.type-admin_broadcast {
    background: rgba(99, 102, 241, 0.12);
    color: #6366f1;
}

.notification-item-icon.type-system {
    background: rgba(107, 114, 128, 0.12);
    color: #6b7280;
}

.notification-item-content {
    flex: 1;
    min-width: 0;
}

.notification-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.notification-item-body {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notification-item-time {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 3px;
}

.notification-dropdown-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--border-light);
    text-align: center;
}

.notification-dropdown-footer a {
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.notification-dropdown-footer a:hover {
    color: #4338ca;
}

.notification-empty {
    padding: 40px 20px;
    text-align: center;
}

.notification-empty svg {
    margin: 0 auto 12px;
}

.notification-empty p {
    font-size: 13px;
    color: #94a3b8;
}

.notification-skeleton {
    padding: 16px;
}

.skeleton-line {
    height: 12px;
    background: linear-gradient(90deg, #f1f5f9, #e2e8f0, #f1f5f9);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
    margin-bottom: 10px;
}

.skeleton-line.short {
    width: 60%;
    margin-bottom: 20px;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Locale switcher */
.locale-switcher {
    display: flex;
    background: var(--border-light);
    border-radius: 6px;
    padding: 2px;
    gap: 2px;
}

.locale-btn {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    background: none;
    cursor: pointer;
    transition: all var(--transition);
}

.locale-btn:hover {
    color: var(--text-primary);
}

.locale-btn.active {
    background: white;
    color: var(--accent-dark);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* User menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--transition);
}

.user-menu:hover {
    background: var(--border-light);
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
}

.user-name {
    font-size: 13px;
    font-weight: 500;
}

/* ============================================================
   Page Content
   ============================================================ */
.page-content {
    padding: 28px 24px;
    flex: 1;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.page-header-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    border: 1px solid var(--border-light);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Stats cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 10px 16px;
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 14px;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.orange { background: rgba(255, 164, 0, 0.12); color: var(--accent); }
.stat-icon.blue { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.stat-icon.green { background: rgba(34, 197, 94, 0.12); color: #22c55e; }
.stat-icon.red { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.stat-icon.purple { background: rgba(168, 85, 247, 0.12); color: #a855f7; }

.stat-content .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-content .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
}

.btn:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--accent);
    color: var(--dark);
}

.btn-primary:hover {
    background: var(--accent-dark);
    box-shadow: 0 4px 12px rgba(255, 164, 0, 0.3);
}

.btn-secondary {
    background: white;
    color: var(--text-primary);
    border: 1.5px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent-dark);
}

.btn-danger {
    background: #fee2e2;
    color: #dc2626;
    border: 1.5px solid #fecaca;
}

.btn-danger:hover {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
}

.btn-success {
    background: #dcfce7;
    color: #16a34a;
    border: 1.5px solid #bbf7d0;
}

.btn-success:hover {
    background: #16a34a;
    color: white;
    border-color: #16a34a;
}

.btn-dark {
    background: var(--dark);
    color: white;
}

.btn-dark:hover {
    background: var(--dark-2);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 15px;
}

.btn-icon {
    padding: 7px;
    width: 34px;
    height: 34px;
}

.btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

/* ============================================================
   Forms
   ============================================================ */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-label .required {
    color: #ef4444;
    margin-left: 2px;
}

.form-control {
    display: block;
    width: 100%;
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: white;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
    line-height: 1.5;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 164, 0, 0.12);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control.is-invalid {
    border-color: #ef4444;
    background: #fff5f5;
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.form-control.is-valid {
    border-color: #22c55e;
    background: #f0fdf4;
}

.form-control.is-valid:focus {
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.12);
}

.form-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.form-error {
    font-size: 12px;
    color: #ef4444;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* Input group */
.input-group {
    display: flex;
    align-items: stretch;
}

.input-group .form-control {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    flex: 1;
}

.input-group-append {
    display: flex;
}

.input-group-append .btn {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    border-left: none;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.form-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ============================================================
   Tables
   ============================================================ */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th {
    background: var(--border-light);
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.table th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.table th:last-child { border-radius: 0 var(--radius-sm) 0 0; }

.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    vertical-align: middle;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover td {
    background: rgba(255, 164, 0, 0.03);
}

.table .actions {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
}

.table .text-right { text-align: right; }
.table .text-center { text-align: center; }

/* ============================================================
   Badges / Status Pills
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-orange {
    background: rgba(255, 164, 0, 0.12);
    color: #d97706;
}

.badge-green {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
}

.badge-gray {
    background: rgba(107, 114, 128, 0.10);
    color: #6b7280;
}

.badge-blue {
    background: rgba(59, 130, 246, 0.12);
    color: #2563eb;
}

.badge-red {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
}

.badge-purple {
    background: rgba(168, 85, 247, 0.12);
    color: #9333ea;
}

/* ============================================================
   Flash Toasts
   ============================================================ */
.flash-messages {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.flash-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    min-width: 280px;
    max-width: 380px;
    pointer-events: all;
    animation: slideIn 0.3s ease;
    border-left: 3px solid transparent;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

.flash-toast.success {
    background: #f0fdf4;
    color: #15803d;
    border-left-color: #22c55e;
}

.flash-toast.error {
    background: #fff5f5;
    color: #dc2626;
    border-left-color: #ef4444;
}

.flash-toast.warning {
    background: #fffbeb;
    color: #d97706;
    border-left-color: #f59e0b;
}

.flash-toast.info {
    background: #eff6ff;
    color: #2563eb;
    border-left-color: #3b82f6;
}

.flash-toast-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.flash-toast-close {
    margin-left: auto;
    width: 20px;
    height: 20px;
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity var(--transition);
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.flash-toast-close:hover {
    opacity: 1;
}

/* ============================================================
   Alert boxes
   ============================================================ */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.alert-error, .alert-danger {
    background: #fff5f5;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}

.alert-info {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

/* ============================================================
   VAT Summary Table (Invoice)
   ============================================================ */
.vat-summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.vat-summary-table th {
    background: var(--border-light);
    padding: 8px 12px;
    text-align: right;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.vat-summary-table th:first-child {
    text-align: left;
}

.vat-summary-table td {
    padding: 8px 12px;
    text-align: right;
    border-bottom: 1px solid var(--border-light);
}

.vat-summary-table td:first-child {
    text-align: left;
    font-weight: 600;
}

.vat-summary-table tfoot td {
    font-weight: 700;
    border-top: 2px solid var(--border);
    padding-top: 10px;
}

.grand-total {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-dark);
}

/* ============================================================
   Invoice line items
   ============================================================ */
.invoice-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 8px;
}

.invoice-items-table th {
    background: var(--dark);
    color: rgba(255,255,255,0.7);
    padding: 8px 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.invoice-items-table td {
    padding: 6px 6px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light);
}

.invoice-items-table td .form-control {
    padding: 6px 10px;
    font-size: 13px;
}

.invoice-items-table .remove-btn {
    color: #ef4444;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background var(--transition);
}

.invoice-items-table .remove-btn:hover {
    background: #fee2e2;
}

/* ============================================================
   Search bar
   ============================================================ */
.search-bar {
    position: relative;
    width: 300px;
}

.search-bar input {
    width: 100%;
    padding: 9px 12px 9px 36px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    background: white;
    transition: border-color var(--transition);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 164, 0, 0.12);
}

.search-bar svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 15px;
    height: 15px;
    pointer-events: none;
}

/* ============================================================
   Pagination
   ============================================================ */
.pagination-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.pagination-info {
    font-size: 13px;
    color: var(--text-secondary);
}

.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination a, .pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    border: 1.5px solid transparent;
}

.pagination a {
    color: var(--text-secondary);
    border-color: var(--border);
}

.pagination a:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent-dark);
}

.pagination span.active {
    background: var(--accent);
    color: var(--dark);
    border-color: var(--accent);
    font-weight: 700;
}

/* ============================================================
   Empty state
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-secondary);
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    background: var(--border-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    color: var(--text-muted);
}

.empty-state-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.empty-state-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* ============================================================
   Filter bar
   ============================================================ */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-bar .form-control {
    width: auto;
    min-width: 140px;
}

/* ============================================================
   GUS lookup
   ============================================================ */
.gus-loading {
    display: none;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 6px;
}

.gus-loading.active {
    display: flex;
}

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   Invoice detail (show page)
   ============================================================ */
.invoice-header-meta {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}

.invoice-party {
    background: var(--border-light);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.invoice-party-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.invoice-party-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.invoice-party-detail {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ============================================================
   Dropdown
   ============================================================ */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    min-width: 180px;
    z-index: 1000;
    padding: 4px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    transition: background var(--transition);
}

.dropdown-item:hover {
    background: var(--border-light);
}

.dropdown-item.danger {
    color: #dc2626;
}

.dropdown-item.danger:hover {
    background: #fee2e2;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* ============================================================
   Searchable picker (company / tenant switcher)
   ============================================================ */
.picker-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 340px;
    max-width: calc(100vw - 32px);
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.picker-search {
    position: sticky;
    top: 0;
    background: white;
    border-bottom: 1px solid var(--border-light);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.picker-search svg { flex-shrink: 0; color: var(--text-muted); }
.picker-search input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 13px;
    color: var(--text-primary);
    background: transparent;
    padding: 2px 0;
}
.picker-search input::placeholder { color: var(--text-muted); }
.picker-search-kbd {
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 10px;
    color: var(--text-muted);
    background: var(--border-light);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
}
.picker-pinned {
    border-bottom: 1px solid var(--border-light);
    padding: 4px;
}
.picker-list {
    overflow-y: auto;
    max-height: 340px;
    padding: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.picker-list::-webkit-scrollbar { width: 8px; }
.picker-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.picker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 6px;
    transition: background var(--transition);
    font-size: 13px;
    color: var(--text-primary);
}
.picker-item:hover, .picker-item.is-highlighted { background: var(--border-light); }
.picker-item.is-active { background: var(--accent-light); }
.picker-item.is-active .picker-item-name { color: var(--dark); font-weight: 600; }
.picker-item-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
}
.picker-item.is-active .picker-item-icon { background: var(--accent); color: var(--dark); }
.picker-item-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.picker-item-name {
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.picker-item-meta {
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.picker-item-check {
    flex-shrink: 0;
    color: var(--accent);
}
.picker-empty {
    padding: 20px 12px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}
.picker-footer {
    border-top: 1px solid var(--border-light);
    padding: 6px 12px;
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    gap: 8px;
}
.picker-footer-kbd { font-family: ui-monospace, SFMono-Regular, monospace; }
.picker-trigger-count {
    background: var(--border-light);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 2px;
}
.picker-mark { background: rgba(255, 164, 0, 0.3); color: var(--text-primary); padding: 0 1px; border-radius: 2px; }

/* ============================================================
   Confirmation modal
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal {
    background: white;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    padding: 28px;
    max-width: 440px;
    width: 100%;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.modal-body {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ============================================================
   Utility
   ============================================================ */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-danger { color: #dc2626; }
.text-success { color: #16a34a; }
.fw-bold { font-weight: 700; }
.fw-600 { font-weight: 600; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.w-full { width: 100%; }

.section-divider {
    height: 1px;
    background: var(--border);
    margin: 24px 0;
}

.monospace {
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

/* ============================================================
   Mobile navigation (hamburger + overlay)
   ============================================================ */
.btn-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    transition: background var(--transition);
    flex-shrink: 0;
    padding: 0;
    touch-action: manipulation;
}

.btn-hamburger:hover {
    background: var(--border-light);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
}

/* ============================================================
   Responsive — 768px (tablet / large phone)
   ============================================================ */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }

    .btn-hamburger {
        display: flex;
    }

    .sidebar, .sidebar.compact {
        width: 250px;
        transform: translateX(-250px);
        transition: transform 0.3s ease;
        z-index: 100;
    }

    .sidebar.open {
        transform: translateX(0);
        width: 250px;
        box-shadow: 0 0 40px rgba(0,0,0,0.3);
    }

    .sidebar.compact .nav-label,
    .sidebar.compact .nav-badge,
    .sidebar.compact .sidebar-section-label,
    .sidebar.compact .sidebar-logo-text {
        display: initial;
    }

    .sidebar.compact .sidebar-nav-item,
    .sidebar.compact .sidebar-footer .sidebar-nav-item {
        justify-content: flex-start;
    }

    .sidebar.compact + .main-wrapper,
    .main-wrapper {
        margin-left: 0;
    }

    .sidebar-compact-toggle {
        display: none;
    }

    .header {
        padding: 0 16px;
    }

    .page-content {
        padding: 16px;
    }

    /* Compact KSeF badge — dot only */
    .ksef-badge span:not(.ksef-badge-dot) {
        display: none;
    }
    .ksef-badge {
        padding: 6px 8px;
        min-width: 28px;
        justify-content: center;
    }

    /* Client context banner — compact on mobile */
    .client-context-banner {
        padding: 0 16px;
    }
    .client-context-banner-inner {
        flex-wrap: wrap;
        gap: 6px;
    }
    .client-context-banner-nip {
        display: none;
    }
    .client-context-banner-label {
        font-size: 11px;
    }
    .client-context-banner-name {
        font-size: 12px;
    }

    /* Hide username, keep avatar */
    .user-name {
        display: none;
    }

    /* Notification dropdown fullscreen on mobile */
    .notification-dropdown {
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        width: 100%;
        max-height: calc(100vh - 56px);
        border-radius: 0;
    }

    /* Form grids collapse */
    .form-row-2, .form-row-3, .form-row-4 {
        grid-template-columns: 1fr;
    }

    .invoice-header-meta {
        grid-template-columns: 1fr;
    }

    /* Stats: 2 columns on tablet */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* Page header wraps */
    .page-header {
        flex-wrap: wrap;
        gap: 12px;
    }

    /* Search bar full width */
    .search-bar {
        width: 100%;
    }

    /* Flash toasts: stretch to screen edges */
    .flash-messages {
        left: 12px;
        right: 12px;
    }
    .flash-toast {
        min-width: unset;
        max-width: 100%;
    }

    /* Smooth touch scrolling on tables */
    .table-wrapper {
        -webkit-overflow-scrolling: touch;
    }
}

/* ============================================================
   Responsive — 480px (small phones, portrait)
   ============================================================ */
@media (max-width: 480px) {
    /* Single-column stats */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Reduce card padding */
    .card {
        padding: 16px;
    }

    /* Fluid page title */
    .page-header-title {
        font-size: clamp(16px, 5vw, 22px);
    }

    /* Pagination stacks vertically */
    .pagination-wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    /* Compact locale switcher */
    .locale-btn {
        padding: 4px 5px;
        font-size: 10px;
    }

    /* Modal slides up from bottom */
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal {
        border-radius: var(--radius) var(--radius) 0 0;
        max-width: 100%;
    }

    /* Ensure minimum touch target size on all interactive elements */
    .btn, .sidebar-nav-item, .locale-btn, .dropdown-item {
        min-height: 44px;
    }

    .btn-sm {
        min-height: 36px;
    }
}

/* Alpine.js cloak — hide elements until Alpine initialises */
[x-cloak] { display: none !important; }
