/* TheCyclistSync Intrastat - Declaration Tool Styles
 * Mirrors the shared portal design system (see /admin/assets/css/style.css),
 * tuned to the Intrastat module's cyan brand accent.
 */

:root {
    --primary-color: #0891b2;
    --primary-hover: #0e7490;
    --secondary-color: #6b7280;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;

    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
    --text-color: #1f2937;
    --text-muted: #6b7280;

    --sidebar-width: 250px;
    --header-height: 60px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    --radius: 8px;
    --radius-sm: 4px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-color);
    background-color: var(--bg-color);
}

a {
    color: var(--primary-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 40px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header p {
    color: var(--text-muted);
}

.login-logo {
    max-width: 150px;
    height: auto;
    margin-bottom: 15px;
}

.back-home-btn {
    display: block;
    text-align: center;
    margin-top: 20px;
    padding: 10px;
    color: var(--text-muted);
    font-size: 14px;
    transition: color 0.2s;
}

.back-home-btn:hover {
    color: var(--primary-color);
    text-decoration: none;
}

.login-form .form-group {
    margin-bottom: 20px;
}

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

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

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group input[type="url"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.12);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.btn:hover {
    text-decoration: none;
}

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

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

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

.btn-secondary:hover {
    background-color: #5b6370;
    color: white;
}

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

.btn-success:hover {
    background-color: #059669;
    color: white;
}

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

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

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn-outline:hover {
    background-color: var(--bg-color);
}

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

.btn-block {
    width: 100%;
}

.btn-icon {
    padding: 8px;
    min-width: 36px;
}

.btn-info {
    background-color: #8ecae6;
    color: #1f2937;
    border: 1px solid #8ecae6;
}

.btn-info:hover {
    background-color: #71b8d9;
    border-color: #71b8d9;
    color: #1f2937;
}

.btn-admin {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    color: white;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.btn-admin:hover {
    background: linear-gradient(135deg, #4338ca 0%, #3730a3 100%);
    color: white;
}

.btn-rentals {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.btn-rentals:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: white;
}

.btn-pos {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.btn-pos:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    color: white;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-info {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

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

/* Sidebar collapse toggle */
.sidebar-collapse-toggle {
    width: 30px;
    height: 30px;
    border-radius: var(--radius);
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    flex-shrink: 0;
}

.sidebar-collapse-toggle:hover {
    background: var(--bg-color);
    color: var(--text-color);
    border-color: var(--text-muted);
}

.sidebar-collapse-toggle svg {
    transition: transform 0.3s ease;
}

.intrastat-layout.sidebar-collapsed .sidebar-collapse-toggle svg {
    transform: rotate(180deg);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: #6c757d;
    color: #e5e7eb;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: width 0.3s ease;
}

.sidebar.collapsed {
    width: 0;
    overflow: hidden;
}

.main-content {
    transition: margin-left 0.3s ease;
}

.intrastat-layout.sidebar-collapsed .main-content {
    margin-left: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #5a6268;
}

.sidebar-logo-tile {
    display: block;
    background: #f3f4f6;
    border-radius: 10px;
    padding: 14px 16px 4px;
    text-align: center;
}

.sidebar-logo-tile img {
    max-width: 100%;
    height: auto;
    display: block;
}

.sidebar-clock {
    margin-top: 8px;
    font-size: 13px;
    color: #9ca3af;
    font-family: monospace;
    letter-spacing: 0.5px;
    text-align: center;
}

.sidebar-nav {
    padding: 16px 0;
}

.sidebar-section-title {
    padding: 4px 20px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #adb5bd;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: #d1d5db;
    transition: all 0.15s;
}

.nav-item:hover {
    background-color: #5a6268;
    color: white;
    text-decoration: none;
}

.nav-item.active {
    background-color: #8ecae6;
    color: #1f2937;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    vertical-align: middle;
    flex-shrink: 0;
}

.nav-divider {
    height: 1px;
    background-color: #5a6268;
    margin: 16px 0;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* Header */
.header {
    height: var(--header-height);
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    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;
}

.header-left h2 {
    font-size: 18px;
    font-weight: 600;
}

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

.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-color);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    transition: background 0.2s;
}

.user-menu:hover {
    background: rgba(0, 0, 0, 0.05);
    text-decoration: none;
}

/* Page Content */
.page-content {
    padding: 24px;
    max-width: 1400px;
}

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

.page-header h1 {
    font-size: 24px;
    font-weight: 600;
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

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

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

.card-hint {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 10px;
}

/* Upload dropzone */
.upload-row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.upload-row input[type="file"] {
    flex: 1;
    min-width: 220px;
    padding: 10px;
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius);
    background: #f8fafc;
    font-size: 14px;
}

.upload-row input[type="file"]:hover {
    border-color: var(--primary-color);
    background: rgba(8, 145, 178, 0.04);
}

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

table th {
    background-color: #f9fafb;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

table tbody tr:hover {
    background-color: #f9fafb;
}

.fname {
    font-weight: 600;
    color: var(--text-color);
}

.muted {
    color: #9ca3af;
    font-size: 12px;
}

.err-msg {
    color: #b91c1c;
    font-size: 12px;
    max-width: 260px;
    margin-top: 4px;
}

.actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.actions form {
    display: inline;
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: #9ca3af;
}

.empty-state svg {
    width: 56px;
    height: 56px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* Review page editable grid */
.review-sub {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 18px;
}

.tablewrap {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.grid-table {
    border-collapse: collapse;
    width: 100%;
    min-width: 1100px;
}

.grid-table th,
.grid-table td {
    border-bottom: 1px solid #eef0f3;
    border-right: 1px solid #f3f4f6;
    padding: 6px;
    font-size: 13px;
    text-transform: none;
}

.grid-table th {
    background: #f8fafc;
    color: #374151;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-align: left;
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.grid-table td input {
    width: 100%;
    min-width: 90px;
    border: 1px solid transparent;
    border-radius: 5px;
    padding: 7px 8px;
    font-size: 13px;
    background: transparent;
    font-family: inherit;
}

.grid-table td input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: #fff;
    box-shadow: 0 0 0 2px rgba(8, 145, 178, 0.12);
}

.grid-table td.rownum {
    color: #9ca3af;
    text-align: center;
    width: 34px;
}

.grid-table td.del {
    width: 40px;
    text-align: center;
}

/* Invoice group header — separates each invoice's line items in a multi-invoice
   scan. Carries no inputs, so it is skipped by row numbering and validation. */
.grid-table tr.grp-row td {
    background: #eef2f7;
    color: #334155;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.02em;
    padding: 7px 10px;
    border-top: 2px solid #cbd5e1;
    position: sticky;
    left: 0;
}

.delrow {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}

.btn-link {
    background: none;
    color: var(--primary-color);
    border: none;
    cursor: pointer;
    font-size: 13px;
    padding: 4px;
    font-weight: 500;
}

.btn-link:hover {
    text-decoration: underline;
}

.action-bar {
    display: flex;
    gap: 10px;
    margin-top: 18px;
    flex-wrap: wrap;
}

/* Mobile menu toggle (hidden on desktop) */
.mobile-menu-toggle {
    display: none;
}

.sidebar-overlay {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
        z-index: 1010;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0, 0, 0, .4);
        z-index: 1005;
    }

    .sidebar-overlay.open {
        display: block;
    }

    .mobile-menu-toggle {
        display: inline-flex !important;
    }

    .main-content {
        margin-left: 0;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Intrastat export panel (Review screen) */
.export-panel {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px 18px;
    margin: 18px 0 8px;
}
.export-panel legend {
    font-weight: 600;
    font-size: 14px;
    padding: 0 6px;
    color: #374151;
}
.export-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}
.export-grid label {
    display: flex;
    flex-direction: column;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    gap: 4px;
}
.export-grid select,
.export-grid input {
    font-weight: 400;
    padding: 7px 9px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    min-width: 150px;
}
.export-grid .period-inputs {
    display: flex;
    gap: 6px;
}
.export-grid .opt,
.form-group .opt {
    font-weight: 400;
    color: #9ca3af;
}

/* ============================================================
   Processing overlay — shown while a slow action (extract /
   upload) runs. Clears automatically when the page reloads
   after the redirect.
   ============================================================ */
.intr-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(17, 24, 39, 0.55);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    animation: intr-fade 0.15s ease-out;
}
@keyframes intr-fade { from { opacity: 0; } to { opacity: 1; } }
.intr-overlay-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 30px 34px;
    max-width: 400px;
    width: 100%;
    text-align: center;
}
.intr-overlay-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 8px;
}
.intr-overlay-sub {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.55;
}

/* Spinning wheel — also usable inline via .intr-spinner-sm */
.intr-spinner {
    display: inline-block;
    width: 44px;
    height: 44px;
    margin: 0 auto 18px;
    border: 4px solid rgba(8, 145, 178, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: intr-spin 0.8s linear infinite;
}
.intr-spinner-sm {
    width: 15px;
    height: 15px;
    margin: 0 6px 0 0;
    border-width: 2px;
    vertical-align: -3px;
}
@keyframes intr-spin { to { transform: rotate(360deg); } }

/* Indeterminate progress bar beneath the spinner */
.intr-progress {
    position: relative;
    height: 4px;
    width: 100%;
    margin-top: 20px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}
.intr-progress::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40%;
    background: var(--primary-color);
    border-radius: 999px;
    animation: intr-slide 1.15s ease-in-out infinite;
}
@keyframes intr-slide {
    0%   { left: -40%; }
    100% { left: 100%; }
}
@media (prefers-reduced-motion: reduce) {
    .intr-spinner { animation-duration: 1.6s; }
    .intr-progress::before { animation: none; left: 0; width: 100%; opacity: 0.5; }
}

/* ============================================================
   Export readiness panel + live invalid-cell highlighting
   (Review screen)
   ============================================================ */
.readiness {
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 16px;
    font-size: 13px;
}
.readiness-ok {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}
.readiness-blocked {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}
.readiness-title {
    font-weight: 600;
    margin-bottom: 6px;
}
.readiness ul {
    margin: 6px 0 0;
    padding-left: 20px;
}
.readiness li { margin: 3px 0; }
.readiness a { text-decoration: underline; color: inherit; }

.grid-table td input.cell-invalid {
    border-color: var(--danger-color);
    background: #fef2f2;
}
.hint-live {
    font-size: 13px;
    font-weight: 500;
    align-self: center;
}
.hint-live.blocked { color: #b45309; }
.hint-live.ok { color: #047857; }

/* ============================================================
   Per-invoice split
   (dashboard invoice list, invoice review, export picker)
   ============================================================ */

/* The row underneath an upload that holds its invoices. */
.inv-hostrow > td {
    background: #f9fafb;
    border-top: none;
    padding: 0 16px 14px;
}
.batch-note {
    background: #fef3c7;
    border: 1px solid #fde68a;
    color: #92400e;
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 13px;
    margin: 10px 0 0;
}
.flag-line {
    margin-top: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #b45309;
}

.inv-details { margin-top: 10px; }
.inv-details > summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary, #4b5563);
    padding: 6px 0;
    user-select: none;
}
.inv-details > summary:hover { color: var(--text-primary, #111827); }

.inv-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-top: 6px;
}
.inv-table th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6b7280;
    background: #f9fafb;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    white-space: nowrap;
}
.inv-table td {
    padding: 9px 10px;
    font-size: 13px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: top;
}
.inv-table tbody tr:last-child td { border-bottom: none; }
.inv-table tr.inv-flagged > td { background: #fffbeb; }
.inv-table .nowrap { white-space: nowrap; }
.inv-table .actions { justify-content: flex-end; }

/* The issue list sits directly under the invoice it belongs to. */
.inv-issues > td {
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
    padding-top: 0;
}
.inv-issues ul {
    margin: 0;
    padding-left: 18px;
    color: #92400e;
    font-size: 12px;
}
.inv-issues li { margin: 2px 0; }

.verdict {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
}
.verdict.v-ok   { background: #d1fae5; color: #065f46; }
.verdict.v-warn { background: #fef3c7; color: #92400e; }
.verdict.v-bad  { background: #fee2e2; color: #991b1b; }

/* Invoice review screen */
.inv-head-actions { display: flex; gap: 8px; }
.inv-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px 20px;
    margin: 0;
}
.inv-facts dt {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6b7280;
    margin-bottom: 2px;
}
.inv-facts dd { margin: 0; font-size: 14px; font-weight: 500; }

/* Amber variant of the readiness panel: worth a look, not fatal. */
.readiness-warn {
    background-color: #fff7ed;
    color: #9a3412;
    border: 1px solid #fed7aa;
}
.readiness-foot { margin: 8px 0 0; }

/* "I have checked this invoice" — the gate on exporting a flagged invoice. */
.ack-box {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-top: 14px;
    font-size: 13px;
    color: #92400e;
    cursor: pointer;
}
.ack-box.ack-on {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}
.ack-box input[type=checkbox] { margin-top: 2px; width: 16px; height: 16px; flex: none; }
.ack-box em { font-style: normal; display: block; margin-top: 3px; }

.pick-table { margin-bottom: 4px; }
.pick-table input[type=checkbox] { width: 16px; height: 16px; }
