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

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

:root {
    --bg: #f5f5f5;
    --surface: #ffffff;
    --text: #111111;
    --text-2: #666666;
    --text-3: #999999;
    --border: #e8e8e8;
    --border-hover: #d0d0d0;
    --accent: #111111;
    --accent-hover: #333333;
    --green: #00a67e;
    --green-bg: #e6f9f1;
    --amber: #e5960a;
    --amber-bg: #fff8e6;
    --red: #e5484d;
    --red-bg: #fef0f0;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --transition: 150ms ease;
}

html { font-size: 14px; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* ========== LOGIN ========== */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #fafafa;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 380px;
    text-align: center;
    box-shadow: var(--shadow);
}

.login-icon { font-size: 40px; margin-bottom: 16px; }
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-subtitle { color: var(--text-2); font-size: 13px; margin-bottom: 24px; }

.login-form { display: flex; flex-direction: column; gap: 12px; }

.login-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: inherit;
    text-align: center;
    letter-spacing: 4px;
    outline: none;
    transition: border-color var(--transition);
}
.login-input:focus { border-color: var(--accent); }

.error-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: var(--shadow);
}
.error-card h2 { margin: 12px 0 8px; font-size: 18px; }

/* ========== TOP BAR ========== */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-logo { font-size: 20px; }
.topbar-brand { font-weight: 600; font-size: 15px; }
.topbar-divider { width: 1px; height: 20px; background: var(--border); }

/* ========== MAIN CONTENT ========== */
.main-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-dark { background: var(--accent); color: #fff; }
.btn-dark:hover { background: var(--accent-hover); }

.btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f5f5f5; border-color: var(--border-hover); color: var(--text); }

.btn-ghost-danger { background: transparent; color: var(--text-3); border: 1px solid transparent; }
.btn-ghost-danger:hover { background: var(--red-bg); color: var(--red); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; padding: 12px; font-size: 14px; }

/* ========== STATS ========== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
}

.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-3); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.05em; }

/* ========== SECTION CARD ========== */
.section-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

.section-heading {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
}

.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
}

/* ========== CREATE FORM ========== */
.create-form {
    display: flex;
    gap: 10px;
}

.input-field {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
    background: #fafafa;
}
.input-field:focus { border-color: var(--accent); background: #fff; }

/* ========== BATCH GRID ========== */
.batch-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.batch-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.batch-card:hover { border-color: var(--border-hover); box-shadow: var(--shadow); }

.batch-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.batch-name { font-size: 15px; font-weight: 600; }

.batch-meta { font-size: 12px; color: var(--text-3); }

.batch-actions {
    display: flex;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    background: #f0f0f0;
    color: var(--text-2);
}

/* ========== UPLOAD ========== */
.upload-form { display: flex; flex-direction: column; gap: 12px; }

.upload-area { position: relative; }

.file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 28px 20px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-2);
    font-size: 13px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
}
.upload-label:hover { border-color: var(--accent); background: #fafafa; }

.upload-icon { font-size: 28px; }

/* ========== DATA TABLE ========== */
.table-scroll { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}

.data-table thead th {
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 12px;
    border-bottom: 1px solid #f5f5f5;
    vertical-align: top;
    font-size: 13px;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafafa; }

/* Cell types */
.cell-serial { width: 40px; text-align: center; font-weight: 600; color: var(--text-3); font-size: 12px; }
.cell-file { min-width: 140px; max-width: 180px; }
.cell-address { min-width: 220px; }
.cell-note { min-width: 140px; }
.cell-status { width: 100px; white-space: nowrap; }
.cell-shipping { min-width: 140px; }
.cell-action { width: 36px; text-align: center; }

/* File display */
.file-display {
    display: flex;
    align-items: center;
    gap: 10px;
}
.file-thumb {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #f5f5f5;
    border: 1px solid var(--border);
    transition: border-color var(--transition);
}
.file-thumb:hover { border-color: var(--accent); }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-ext { font-size: 10px; font-weight: 700; color: var(--red); letter-spacing: 0.05em; }
.file-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--accent);
    line-height: 1.3;
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Address Grid */
.address-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.address-row {
    display: flex;
    gap: 8px;
}
.input-minimal {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 12px;
    background: #fafafa;
    outline: none;
    transition: all var(--transition);
}
.input-minimal:hover { border-color: var(--border); }
.input-minimal:focus {
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 2px rgba(17,17,17,0.06);
}
.input-half { flex: 1; min-width: 0; }

/* Textarea in cells */
.cell-textarea {
    width: 100%;
    min-height: 48px;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 12px;
    line-height: 1.5;
    resize: vertical;
    background: #fafafa;
    outline: none;
    transition: all var(--transition);
}
.cell-textarea:hover { border-color: var(--border); }
.cell-textarea:focus {
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 2px rgba(17,17,17,0.06);
}

.address-text { font-size: 12px; line-height: 1.5; }
.shipping-text { font-size: 12px; line-height: 1.5; }

/* ========== TOGGLE SWITCH ========== */
.toggle { position: relative; display: inline-block; width: 36px; height: 20px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-track {
    position: absolute;
    inset: 0;
    background: #ddd;
    border-radius: 20px;
    transition: background var(--transition);
}
.toggle-track::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    left: 2px;
    top: 2px;
    transition: transform var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle input:checked + .toggle-track { background: var(--green); }
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }

.status-text { display: block; font-size: 11px; font-weight: 500; margin-top: 4px; }
.is-pending { color: var(--amber); }
.is-ready { color: var(--green); }

/* ========== PILLS (customer view) ========== */
.pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    gap: 4px;
}
.pill-green { background: var(--green-bg); color: var(--green); }
.pill-amber { background: var(--amber-bg); color: var(--amber); }

/* ========== DELETE BUTTON ========== */
.btn-icon-delete {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    transition: all var(--transition);
}
.btn-icon-delete:hover { background: var(--red-bg); color: var(--red); }

/* ========== ALERTS ========== */
.alert {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
}
.alert-success { background: var(--green-bg); color: var(--green); }
.alert-error { background: var(--red-bg); color: var(--red); }

/* ========== EMPTY STATE ========== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-3); font-size: 13px; }
.empty-icon { font-size: 36px; margin-bottom: 8px; }

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal-box {
    background: var(--surface);
    border-radius: 14px;
    max-width: 380px;
    width: 100%;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    transform: scale(0.96);
    transition: transform 200ms;
}
.modal-overlay.active .modal-box { transform: scale(1); }

.modal-box-header { padding: 20px 24px 0; font-weight: 600; font-size: 16px; }
.modal-box-body { padding: 12px 24px 20px; font-size: 13px; color: var(--text-2); line-height: 1.6; }
.modal-box-footer { padding: 12px 24px 20px; display: flex; justify-content: flex-end; gap: 8px; }

/* ========== TOAST ========== */
.toast-wrap {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast-item {
    background: var(--accent);
    color: #fff;
    padding: 10px 18px;
    border-radius: var(--radius);
    font-size: 13px;
    box-shadow: var(--shadow-md);
    transform: translateY(20px);
    opacity: 0;
    transition: all 300ms cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 320px;
}
.toast-item.visible { transform: translateY(0); opacity: 1; }
.toast-item.toast-success { background: var(--green); }
.toast-item.toast-error { background: var(--red); }

/* ========== SAVE STATUS ========== */
.save-status {
    font-size: 10px;
    font-weight: 500;
    margin-top: 3px;
    opacity: 0;
    transition: opacity var(--transition);
    display: block;
}
.save-status.visible { opacity: 1; }

/* ========== UTILITIES ========== */
.text-muted { color: var(--text-3); }
.text-sm { font-size: 12px; }

/* ========== RESPONSIVE ========== */
@media (min-width: 640px) {
    .batch-grid { grid-template-columns: repeat(2, 1fr); }
}

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

@media (max-width: 639px) {
    .topbar-inner { padding: 0 16px; }
    .main-content { padding: 16px; }
    .section-card { padding: 16px; }
    .table-scroll { margin: 0 -16px; padding: 0 16px; }
    .stats-row { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 16px; }
    .stat-value { font-size: 22px; }
    .create-form { flex-direction: column; }
    .login-card { padding: 36px 28px; }
    .topbar-right { gap: 4px; }
    .batch-actions { flex-wrap: wrap; }
}
