/* ── Reset & Variables ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --bg: #f0f4fa;
    --bg-2: #f8faff;
    --card: #ffffff;
    --line: #dde5f2;
    --text: #111d33;
    --text-2: #3a4f6f;
    --muted: #6b82a6;
    --brand: #1a5fb4;
    --brand-2: #2a7de9;
    --brand-3: #3d93ff;
    --brand-soft: #e8f1ff;
    --accent: #f59e0b;
    --accent-soft: #fef3c7;
    --success-bg: #e5f7ee;
    --success-text: #0b6f44;
    --error-bg: #ffe8e8;
    --error-text: #8f1c1c;
    --radius: 16px;
    --radius-sm: 12px;
    --shadow-card: 0 4px 24px rgba(17,40,76,0.06), 0 1px 3px rgba(17,40,76,0.04);
    --shadow-lg: 0 12px 40px rgba(10,30,60,0.12);
    --transition: .22s cubic-bezier(.4,0,.2,1);
}

/* ── Typography & Base ── */
body {
    font-family: "Heebo", "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
h2 {
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1.3;
    margin-bottom: 4px;
    color: var(--text);
}
h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
p { color: var(--muted); line-height: 1.55; }

/* ── Login ── */
.login-body {
    display: grid;
    place-items: center;
    min-height: 100dvh;
    padding: 20px;
    background: linear-gradient(160deg, #0d1b36 0%, #14325e 50%, #1a5fb4 100%);
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--card);
    border-radius: 22px;
    padding: 28px 22px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.25);
    animation: fadeUp .4s ease;
}
.login-card h2 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 16px;
    color: var(--brand);
}

/* ── Topbar ── */
.topbar {
    background: linear-gradient(135deg, #0d1b36 0%, #142e56 60%, #1a5fb4 100%);
    color: #fff;
    padding: 16px 16px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 4px 20px rgba(6,24,50,0.18);
}
.topbar strong {
    font-size: 1.2rem;
    font-weight: 900;
    display: block;
    letter-spacing: -.2px;
}
.title-wrap { min-width: 0; flex: 1; }
.title-wrap .small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: .7;
    font-size: 12px;
    margin-top: 2px;
}

/* ── Bottom Tabs ── */
.tabs {
    display: flex;
    gap: 6px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background: rgba(255,255,255,0.92);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid rgba(0,0,0,0.06);
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 25;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    text-decoration: none;
    color: var(--muted);
    background: transparent;
    border: none;
    border-radius: 12px;
    text-align: center;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    transition: color var(--transition), background var(--transition);
    position: relative;
}
.tab-icon { font-size: 20px; line-height: 1; display: block; }
.tab.active {
    color: var(--brand);
    background: var(--brand-soft);
    font-weight: 800;
}
.tab:active { transform: scale(.95); }

/* ── Container ── */
.container {
    padding: 16px 14px calc(100px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 720px;
    margin: 0 auto;
}

/* ── Cards ── */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 16px;
    box-shadow: var(--shadow-card);
    animation: fadeUp .35s ease both;
    overflow-x: auto;
}
.card:nth-child(2) { animation-delay: .06s; }
.card:nth-child(3) { animation-delay: .12s; }
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Small text ── */
.small { font-size: 12.5px; color: var(--muted); }

/* ── Forms ── */
label {
    display: block;
    margin-top: 14px;
    margin-bottom: 2px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-2);
    letter-spacing: .1px;
}
label:first-child { margin-top: 0; }

input, select, textarea {
    width: 100%;
    margin-top: 4px;
    padding: 11px 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    background: var(--bg-2);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
    -webkit-appearance: none;
    appearance: none;
}
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b82a6' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 14px center;
    padding-left: 36px;
    cursor: pointer;
}
[dir="ltr"] select {
    background-position: right 14px center;
    padding-left: 14px;
    padding-right: 36px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand-2);
    box-shadow: 0 0 0 3px rgba(42,125,233,0.12);
    background: #fff;
}
input[type="file"] {
    padding: 10px;
    font-size: 13px;
}

/* ── Buttons ── */
button {
    width: 100%;
    margin-top: 8px;
    padding: 12px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
    min-height: 48px;
    background: linear-gradient(135deg, var(--brand-2), var(--brand));
    color: #fff;
    box-shadow: 0 4px 14px rgba(26,95,180,0.22);
    transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
    position: relative;
    overflow: hidden;
}
button:active {
    transform: scale(.97);
    box-shadow: 0 2px 6px rgba(26,95,180,0.18);
}
button.secondary {
    background: var(--bg-2);
    color: var(--text-2);
    box-shadow: none;
    border: 1.5px solid var(--line);
}
button.secondary:active { background: #edf1f8; }

/* ── Inline grid ── */
.inline {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}

/* ── Dashboard Grid Links ── */
.grid-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 14px;
}
.card-link {
    text-decoration: none;
    background: var(--card);
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 14px;
    color: var(--text);
    font-weight: 700;
    font-size: 13px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    box-shadow: var(--shadow-card);
}
.card-link:active {
    transform: scale(.96);
}
.card-link-icon {
    font-size: 28px;
    line-height: 1;
    display: block;
}
.card-link-repair {
    background: linear-gradient(180deg, #fffaf0, #fff5e0);
    border-color: #f0d5ab;
    color: #7a4a00;
}

/* ── Badges ── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .2px;
}
.badge-ok {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid #b7e8ca;
}
.badge-missing {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid #f2c0c0;
}

/* ── Danger button ── */
.btn-danger-outline {
    display: inline-block;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    border: 2px solid #c0392b;
    background: #fff5f5;
    color: #c0392b;
    font-weight: 800;
    font-size: 15px;
    min-height: 48px;
    cursor: pointer;
}
.mt-form { margin-top: 18px; }
.muted { color: var(--muted); font-size: .9rem; margin-top: 4px; }

/* ── Alerts ── */
.alert {
    margin: 12px 14px 0;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideDown .3s ease;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
.alert.success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: #b7e8ca;
}
.alert.success::before { content: "✓"; font-size: 18px; }
.alert.error {
    background: var(--error-bg);
    color: var(--error-text);
    border-color: #f2c0c0;
}
.alert.error::before { content: "✕"; font-size: 18px; }
.alert.fade-out {
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity .4s ease, transform .4s ease;
}

/* ── Tables ── */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 12px;
    font-size: 13.5px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}
th, td {
    border-bottom: 1px solid #edf1f8;
    padding: 10px 12px;
    text-align: start;
    white-space: nowrap;
}
tr:last-child td { border-bottom: 0; }
th {
    color: var(--text-2);
    font-weight: 700;
    background: #f5f8fd;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .4px;
}
tbody tr { transition: background var(--transition); }
tbody tr:active { background: #f5f9ff; }

/* ── Popups / Modals ── */
.popup {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
    padding: 0;
    animation: overlayIn .25s ease;
}
@keyframes overlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.popup-box {
    width: 100%;
    max-width: 520px;
    background: #fff;
    border-radius: 22px 22px 0 0;
    padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 40px rgba(0,0,0,0.15);
    animation: sheetUp .3s cubic-bezier(.32,.72,0,1);
}
@keyframes sheetUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.popup-box h3 {
    font-size: 1.15rem;
    margin-bottom: 8px;
}
.popup-box p {
    margin-bottom: 14px;
    font-size: 14px;
}

.hidden { display: none !important; }

/* ── Collapsible ── */
.collapsible {
    margin-top: 12px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height .35s cubic-bezier(.4,0,.2,1), opacity .25s ease, margin .25s ease;
}
.collapsible.open {
    max-height: 1200px;
    opacity: 1;
}

/* ── Button row ── */
.btn-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}
.btn-row button,
.btn-row .btn-link {
    width: auto;
    min-width: 0;
    flex: 1;
    min-height: 42px;
    font-size: 13px;
    padding: 10px 16px;
}

.btn-link {
    text-decoration: none;
    background: var(--bg-2);
    color: var(--text-2);
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    display: inline-block;
    text-align: center;
    font-weight: 700;
    font-size: 13px;
}

/* ── Logout ── */
.logout-form { width: auto; flex-shrink: 0; }
.logout-form button {
    min-height: 36px;
    padding: 7px 16px;
    margin-top: 0;
    font-size: 13px;
    background: rgba(255,255,255,0.12);
    color: #fff;
    box-shadow: none;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 10px;
    min-width: 80px;
    width: auto;
}
.logout-form button:active { background: rgba(255,255,255,0.22); }

/* ── Section title extras ── */
.section-subtitle {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 8px;
}

/* ── Responsive tweaks ── */
@media (max-width: 390px) {
    .topbar { flex-wrap: wrap; gap: 8px; }
    .logout-form { width: 100%; }
    .logout-form button { width: 100%; }
    .topbar strong { font-size: 1.1rem; }
    .grid-links { grid-template-columns: 1fr; }
}
@media (min-width: 391px) and (max-width: 600px) {
    .grid-links { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 601px) {
    .grid-links { grid-template-columns: 1fr 1fr 1fr; }
    .inline { grid-template-columns: 1fr 1fr; }
}

/* ── Action buttons (table) ── */
.actions-cell {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: nowrap;
}
.btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    border: none;
    min-height: 32px;
    white-space: nowrap;
    transition: transform var(--transition), opacity var(--transition);
    text-decoration: none;
    width: auto;
    margin: 0;
    box-shadow: none;
}
.btn-sm:active { transform: scale(.95); }
.btn-edit {
    background: var(--brand-soft);
    color: var(--brand);
    border: 1px solid rgba(26,95,180,0.2);
}
.btn-delete {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid #f2c0c0;
}
.inline-form {
    display: inline;
    margin: 0;
    padding: 0;
}
.inline-form button {
    margin: 0;
    width: auto;
}

/* ── Lightbox ── */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
    animation: overlayIn .2s ease;
    cursor: pointer;
}
.lightbox-overlay img {
    max-width: 95vw;
    max-height: 75vh;
    border-radius: 12px;
    object-fit: contain;
    box-shadow: 0 12px 60px rgba(0,0,0,0.5);
    cursor: default;
}
.lightbox-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}
.lightbox-actions a,
.lightbox-actions button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    border: none;
    min-height: 42px;
    text-decoration: none;
    width: auto;
    margin: 0;
}
.lightbox-download {
    background: linear-gradient(135deg, var(--brand-2), var(--brand));
    color: #fff;
    box-shadow: 0 4px 14px rgba(26,95,180,0.3);
}
.lightbox-close {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.25) !important;
    box-shadow: none !important;
}

/* ── Goods image thumbnail ── */
img.preview {
    width: 64px;
    height: 64px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid var(--line);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
}
img.preview:hover,
img.preview:active {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

/* ── Reports ── */
.report-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}
.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    border: 2px solid var(--brand);
    background: var(--brand-soft);
    color: var(--brand);
    width: auto;
    min-height: 42px;
    transition: background var(--transition), color var(--transition);
}
.btn-secondary:hover {
    background: var(--brand);
    color: #fff;
}
#report-capture {
    padding: 20px;
    background: #fff;
    border-radius: 12px;
}
.report-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--line);
}
.report-header h2 {
    font-size: 22px;
    color: var(--brand);
    margin-bottom: 6px;
}
.report-period {
    font-size: 14px;
    color: var(--muted);
    direction: ltr;
}
.report-count {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 14px;
    background: var(--brand-soft);
    color: var(--brand);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
}
.report-table {
    width: 100%;
    border-collapse: collapse;
}
.report-table thead th {
    background: var(--brand);
    color: #fff;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}
.report-table thead th:first-child {
    border-radius: 8px 0 0 0;
}
.report-table thead th:last-child {
    border-radius: 0 8px 0 0;
}
[dir="rtl"] .report-table thead th:first-child {
    border-radius: 0 8px 0 0;
}
[dir="rtl"] .report-table thead th:last-child {
    border-radius: 8px 0 0 0;
}
.report-table tbody td {
    padding: 10px 12px;
    font-size: 13px;
    border-bottom: 1px solid var(--line);
}
.report-table tbody tr:nth-child(even) {
    background: var(--bg-2);
}
.report-table tbody tr:hover {
    background: var(--brand-soft);
}
