:root {
    --bg: #eef2ff;
    --surface: rgba(255, 255, 255, 0.75);
    --surface-strong: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #dbe4f3;
    --primary: #3b82f6;
    --primary-strong: #1d4ed8;
    --primary-soft: #eff6ff;
    --success: #059669;
    --danger: #dc2626;
    --shadow: 0 18px 42px rgba(15, 23, 42, 0.12);
    --radius: 18px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Inter", "Segoe UI", Arial, Helvetica, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 10% 0%, #bfdbfe 0%, transparent 35%),
        radial-gradient(circle at 90% 5%, #c4b5fd 0%, transparent 30%),
        linear-gradient(180deg, #f8fbff 0%, #eef2ff 100%);
    min-height: 100vh;
}

.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 28px 20px 48px;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    padding: 8px;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    border-radius: 24px;
    box-shadow: var(--shadow);
    width: fit-content;
}

.tab-btn {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 15px;
    font-weight: 700;
    padding: 12px 20px;
    border-radius: 16px;
    cursor: pointer;
    transition: 0.25s ease;
}

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

.tab-btn.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
    color: #fff;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.35);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.section { margin-top: 22px; }
.bulk-toolbar {
    position: fixed;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    width: min(1320px, calc(100vw - 24px));
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    z-index: 900;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
}
.bulk-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bulk-btn { border: 1px solid #cbd5e1; background: #f8fafc; border-radius: 10px; padding: 8px 12px; cursor: pointer; font-weight: 700; }
.bulk-btn.primary { color: #fff; border: none; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%); }
.bulk-btn.danger { color: #fff; border: none; background: linear-gradient(135deg, #ef4444 0%, var(--danger) 100%); }
.bulk-date-wrap { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.bulk-date-wrap input { border: 1px solid #d1dff3; border-radius: 8px; padding: 6px; }

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--border);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
    cursor: pointer;
    user-select: none;
}

.section-title-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-badge {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(145deg, #dbeafe 0%, #eff6ff 100%);
    color: var(--primary-strong);
    font-weight: 800;
}

.section-title-text { font-weight: 800; font-size: 20px; }
.section-count { font-size: 14px; color: var(--muted); }
.chevron { transition: 0.25s; color: var(--muted); }
.section-title.collapsed .chevron { transform: rotate(-90deg); }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 16px;
    margin-top: 14px;
    overflow: hidden;
    transition: 0.3s;
}

.grid.hidden {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    pointer-events: none;
}

.card {
    display: flex;
    gap: 14px;
    position: relative;
    overflow: hidden;
    background: linear-gradient(145deg, #ffffff 0%, #f8fbff 55%, #eef5ff 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    min-height: 130px;
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}
.card-select { position: absolute; top: 10px; right: 10px; width: 18px; height: 18px; z-index: 1; }
.card.selected {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.card::after {
    content: "";
    position: absolute;
    inset: -40% auto auto -20%;
    width: 60%;
    height: 180%;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0) 15%, rgba(255, 255, 255, 0.55) 50%, rgba(255, 255, 255, 0) 85%);
    transform: rotate(14deg);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    display: none;
}

.card:hover {
    transform: translateY(-5px);
    border-color: #9fb8e1;
    box-shadow: 0 18px 34px rgba(30, 64, 175, 0.14);
}

.card:hover::after { opacity: 0; }

.card.active {
    border-color: #6ea0eb;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.24), 0 18px 34px rgba(30, 64, 175, 0.16);
}

.card img {
    width: 84px;
    height: 108px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid #dbe4f3;
}

.info { flex: 1; font-size: 14px; color: var(--text); }
.name { font-weight: 700; font-size: 16px; margin-bottom: 8px; }
.info div:not(.name) { color: var(--muted); margin-bottom: 4px; }

.status {
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.06);
}

.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; }
.status.unknown { background: #f3f4f6; color: #6b7280; }
.status.unknown::before { background: #9ca3af; animation: pulse 1.3s infinite; }
.status.in { background: #ecfdf5; color: var(--success); }
.status.in::before { background: #10b981; }
.status.out { background: #fef2f2; color: #b91c1c; }
.status.out::before { background: #ef4444; }

@keyframes pulse {
    0%,100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.5; }
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.55);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 2000;
}

.modal.show { display: flex; }
.modal.search-mode .date-group,
.modal.search-mode #refreshBtn,
.modal.search-mode #downloadBtn {
    display: none;
}
.modal.search-mode .modal-content {
    width: 560px;
    max-width: 95vw;
    max-height: none;
}

.modal.search-mode .modal-body {
    padding: 0;
    min-height: 0;
}

.modal-content {
    width: 980px;
    max-width: 95vw;
    max-height: 90vh;
    overflow: hidden;
    background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
    border-radius: 24px;
    border: 1px solid #d7e2f3;
    box-shadow: 0 30px 90px rgba(2, 6, 23, 0.34);
    animation: modalIn 0.2s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 1px solid #e9eef7;
    background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
}

.modal-title { font-size: 20px; font-weight: 800; margin: 0; }
.modal-controls { display: flex; align-items: center; gap: 10px; }

.date-group {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f5f7fb;
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.date-label { font-size: 12px; color: #64748b; font-weight: 700; }
.date-input { border: none; background: transparent; outline: none; color: #0f172a; }

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    background: #f3f4f6;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: 0.2s;
}

.icon-btn:hover { transform: translateY(-2px); background: #e5e7eb; }
.icon-btn svg { width: 18px; height: 18px; stroke: #334155; fill: none; stroke-width: 2; }
.icon-btn.primary { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%); }
.icon-btn.primary svg, .icon-btn.danger svg { stroke: white; }
.icon-btn.danger { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }

.modal-body {
    padding: 20px;
    min-height: 300px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.placeholder, .empty-state { text-align: center; color: #7c8aa2; margin-top: 40px; font-size: 16px; }

.search-box {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 8px;
}

#searchInput {
    flex: 1;
    min-width: 250px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #d1dff3;
    background: #fff;
    font-size: 15px;
    outline: none;
}

#searchInput:focus {
    border-color: #7daaf0;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.search-btn {
    width: auto;
    min-width: 110px;
    padding: 0 16px;
    color: white;
    font-weight: 700;
}

.search-results {
    margin-top: 16px;
    display: grid;
    gap: 10px;
}

.search-result-item {
    cursor: pointer;
    background: #fff;
    border: 1px solid #dbe4f3;
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
    font-size: 15px;
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
    overflow: hidden;
}

.search-preview-card {
    max-width: none;
    width: 100%;
    margin: 0;
    border: none;
    border-radius: 0;
    min-height: 220px;
}

.add-btn {
    margin-top: auto;
    display: inline-flex;
    max-width: 100%;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border: none;
    border-radius: 999px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
    font-weight: 700;
    cursor: pointer;
}

.add-btn::before {
    display: none;
}

.add-btn:hover {
    filter: brightness(1.03);
}

.add-btn:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    filter: none;
}

.search-col {
    padding: 12px 14px;
    border-right: 1px solid #e5e7eb;
    word-break: break-word;
}

.search-col:last-child {
    border-right: none;
}

.search-col-main {
    font-weight: 700;
}

.search-card-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-items: center;
    padding: 20px;
}

.search-card-modal[hidden] {
    display: none;
}

.search-card-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.55);
    backdrop-filter: blur(8px);
}

.search-card-container {
    position: relative;
    z-index: 1;
    width: min(420px, 95vw);
}

.search-card-container .card {
    min-height: 108px;
    padding-top: 0;
    padding-bottom: 0;
    align-items: stretch;
}

.search-card-container .card img {
    height: 100%;
    margin: 14px 0;
}

.search-card-container .card .info {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 14px;
    padding-bottom: 14px;
    min-height: 108px;
    box-sizing: border-box;
    overflow: hidden;
}

.search-card-container .card .info div:not(.name) {
    margin-bottom: 2px;
}

.search-card-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.delete-confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 1500;
    display: grid;
    place-items: center;
    padding: 20px;
}

.delete-confirm-modal[hidden] {
    display: none;
}

.delete-confirm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.58);
    backdrop-filter: blur(8px);
}

.delete-confirm-dialog {
    position: relative;
    z-index: 1;
    width: min(460px, 95vw);
    padding: 24px;
    border: 1px solid rgba(254, 202, 202, 0.9);
    border-radius: 22px;
    background: linear-gradient(180deg, #ffffff 0%, #fff7f7 100%);
    box-shadow: 0 24px 70px rgba(127, 29, 29, 0.28);
    animation: modalIn 0.22s ease;
}

.delete-confirm-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    margin-bottom: 14px;
    border-radius: 999px;
    background: #fee2e2;
    color: var(--danger);
    font-size: 26px;
    font-weight: 900;
}

.delete-confirm-content h2 {
    margin: 0 0 10px;
    font-size: 22px;
}

.delete-confirm-content p {
    margin: 0 0 10px;
    color: var(--muted);
    line-height: 1.5;
}

.delete-confirm-note {
    padding: 12px;
    border: 1px solid #fed7aa;
    border-radius: 14px;
    background: #fff7ed;
}

.delete-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.search-error {
    margin-top: 10px;
    color: #b91c1c;
    font-size: 14px;
}

@keyframes modalIn {
    from { transform: scale(0.96); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.report-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.1);
    table-layout: fixed;
}

.report-table th,
.report-table td {
    padding: 8px 7px;
    text-align: center;
    border-bottom: 1px solid #e5e7eb;
    border-right: 1px solid #e5e7eb;
    vertical-align: middle;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
}

.report-table th:last-child,
.report-table td:last-child { border-right: none; }
.report-table tr:last-child td { border-bottom: none; }

.report-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: linear-gradient(180deg, #eaf2ff 0%, #dfe9ff 100%);
    color: #0f172a;
    font-weight: 800;
    border-bottom: 1px solid #b9c9e5;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.report-table tbody tr:nth-child(even) td { background: #f7faff; }
.report-table tbody tr:hover td { background: #e9f1ff; }

.table-wrapper {
    max-height: 420px;
    overflow-x: hidden;
    overflow-y: auto;
    border: 1px solid #d1dff3;
    border-radius: 16px;
    background: #fff;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}

.report-table td:nth-child(1),
.report-table th:nth-child(1) { width: 90px; }
.empty { background-color: #f8fafc; color: #9ca3af; }

.summary {
    margin-top: 14px;
    padding: 14px 16px;
    border: 1px solid #dbe3f0;
    border-radius: 16px;
    background: linear-gradient(180deg, #ffffff 0%, #f5f9ff 100%);
    font-size: 14px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
}
