:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-muted: #64748b;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --info: #3b82f6;
    --info-bg: #eff6ff;
    --purple: #8b5cf6;
    --purple-bg: #f5f3ff;
    --teal: #0d9488;
    --teal-bg: #f0fdfa;
    --radius: 10px;
    --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 28px -4px rgba(15, 23, 42, 0.14);
}

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

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

/* Auth / Login Screen */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #eef2ff 0%, #f8fafc 50%, #f0fdfa 100%);
    padding: 20px;
}

.login-card {
    background: var(--surface);
    width: 100%;
    max-width: 430px;
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.login-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.login-card h1 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
}

.login-card p {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 24px;
}

/* Top Navbar */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 24px;
}

.brand-title {
    font-size: 17px;
    font-weight: 800;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.nav-tabs {
    display: flex;
    gap: 6px;
}

.nav-tab {
    background: transparent;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13.5px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.nav-tab:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.nav-tab.active {
    background: var(--primary-light);
    color: var(--primary);
}

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

.user-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    background: var(--surface-hover);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid var(--border);
}

.role-badge {
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 99px;
    font-weight: 700;
    text-transform: uppercase;
}
.role-admin { background: #fee2e2; color: #b91c1c; }
.role-staff { background: #dbeafe; color: #1d4ed8; }
.role-customer { background: #d1fae5; color: #047857; }

.lang-switch {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
}
.lang-switch:hover {
    border-color: var(--primary);
}

/* Main Container */
.main-container {
    max-width: 1720px;
    margin: 0 auto;
    padding: 18px 20px 60px;
}

/* Ledger Summary Bar */
.ledger-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 13px 16px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat-card.highlight-debt {
    border-left: 4px solid var(--danger);
    background: #fffafa;
}

.stat-card.highlight-earn {
    border-left: 4px solid var(--success);
    background: #f6fef9;
}

.stat-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

/* Toolbar & Filters */
.board-toolbar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

.status-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.status-pill {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
}

.status-pill:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.status-pill.active {
    background: var(--text);
    color: #fff;
    border-color: var(--text);
}

.pill-count {
    background: rgba(100, 116, 139, 0.15);
    padding: 1px 6px;
    border-radius: 99px;
    font-size: 11px;
}
.status-pill.active .pill-count {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.toolbar-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

/* Inputs & Buttons */
.input, .select, .textarea {
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 7px 11px;
    font-size: 13.5px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}

.input:focus, .select:focus, .textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.btn {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 7px 13px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-xs {
    padding: 4px 9px;
    font-size: 12px;
    border-radius: 6px;
}

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

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover { background: #059669; }

.btn-warning {
    background: var(--warning);
    color: #fff;
}
.btn-warning:hover { background: #d97706; }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: #dc2626; }

.btn-outline {
    background: var(--surface);
    border-color: var(--border-strong);
    color: var(--text);
}
.btn-outline:hover { background: var(--surface-hover); }

/* Smart Grid Table */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}

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

.smart-table th {
    background: #f1f5f9;
    color: #334155;
    font-weight: 700;
    text-align: left;
    padding: 11px 12px;
    border-bottom: 1px solid var(--border-strong);
    white-space: nowrap;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.smart-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.smart-table tr:hover td {
    background-color: #f8fafc;
}

.smart-table tr.row-revision td {
    background-color: #fff5f5;
}

.smart-table tr.row-export_req td {
    background-color: #fffbeb;
}

.smart-table tr.row-done td {
    background-color: #f8fafc;
    opacity: 0.92;
}

/* Inline Editable Cells */
.inline-input {
    width: 100%;
    min-width: 100px;
    border: 1px solid transparent;
    background: transparent;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    transition: all 0.15s;
}

.inline-input:hover {
    border-color: var(--border-strong);
    background: #fff;
}

.inline-input:focus {
    border-color: var(--primary);
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-pending { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.badge-doing { background: var(--info-bg); color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge-review { background: var(--purple-bg); color: #6d28d9; border: 1px solid #ddd6fe; }
.badge-export_req { background: var(--warning-bg); color: #b45309; border: 1px solid #fde68a; }
.badge-exported { background: var(--teal-bg); color: #0f766e; border: 1px solid #99f6e4; }
.badge-revision { background: var(--danger-bg); color: #b91c1c; border: 1px solid #fecaca; animation: pulseBorder 2s infinite; }
.badge-done { background: var(--success-bg); color: #047857; border: 1px solid #a7f3d0; }

@keyframes pulseBorder {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15); }
}

/* Thumbnail & Links */
.sample-cell {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    min-width: 210px;
}

.thumb-box {
    width: 52px;
    height: 52px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: #f1f5f9;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
}

.thumb-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.link-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.link-chip:hover {
    background: #e0e7ff;
    text-decoration: underline;
}

.revision-alert-box {
    margin-top: 6px;
    padding: 6px 8px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: #991b1b;
    font-size: 12px;
}

/* Kanban View */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(6, minmax(260px, 1fr));
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 12px;
}

.kanban-col {
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    min-height: 540px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.kanban-col-header {
    font-weight: 700;
    font-size: 13px;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kanban-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kanban-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 700;
}

/* Modals */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal-backdrop.open {
    display: flex;
}

.modal-box {
    background: var(--surface);
    border-radius: 14px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    padding: 24px;
}

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

.modal-header h3 {
    font-size: 17px;
    font-weight: 700;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-group {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group.full {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 12.5px;
    font-weight: 600;
    color: #334155;
}

.paste-zone {
    border: 2px dashed var(--border-strong);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    background: #f8fafc;
    cursor: pointer;
    font-size: 12.5px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.paste-zone:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.paste-zone img {
    max-height: 70px;
    border-radius: 6px;
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    cursor: zoom-out;
}
.lightbox.open { display: flex; }
.lightbox img {
    max-width: 92vw;
    max-height: 92vh;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: #1e293b;
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 8px;
}

@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; }
    .topbar { height: auto; padding: 10px 14px; flex-wrap: wrap; gap: 10px; }
}
