/* Finexy light theme — v3 */
:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

    /* surfaces */
    --bg:            #F1F1EF;
    --sidebar-bg:    #FFFFFF;
    --surface:       #FFFFFF;
    --surface-2:     #F9F9F7;
    --border:        #ECECEA;
    --border-subtle: #F1F1EF;

    /* text */
    --text-primary:  #1A1A1A;
    --text-secondary:#6B7280;
    --text-tertiary: #9CA3AF;
    --text-muted:    #C4C4C2;

    /* accent */
    --accent:        #FF5C35;
    --accent-hover:  #E84E2A;
    --accent-soft:   #FFF0EC;

    /* 4-tone palette */
    --coral:      #FF5C35;  --coral-soft: #FFF0EC;
    --blue:       #3B82F6;  --blue-soft:  #EFF5FF;
    --green:      #16A34A;  --green-soft: #EBF7EF;
    --amber:      #F59E0B;  --amber-soft: #FEF6E7;

    /* semantic */
    --positive:      #16A34A;
    --negative:      #DC2626;

    /* elevation */
    --radius:        16px;
    --radius-sm:     10px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow:    0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.05);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.10);

    --sidebar-width: 200px;
    /* legacy compat */
    --primary: #FF5C35;
    --primary-dark: #E84E2A;
    --success: #16A34A;
    --warning: #D97706;
    --error:   #DC2626;
    --info:    #FF5C35;
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Layout ── */
.app { display: flex; height: 100vh; background: var(--bg); overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.logo-row {
    padding: 16px 14px 13px;
    display: flex;
    align-items: center;
    gap: 9px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.logo-box {
    width: 26px; height: 26px;
    background: var(--accent);
    border: none;
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.logo-box i { font-size: 13px; color: #fff; }
.logo-name  { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.logo-tag   { font-size: 10px; color: var(--text-tertiary); margin-top: 1px; }

.nav { padding: 8px 8px; flex: 1; overflow-y: auto; }

.nlbl {
    display: block;
    font-size: 10px; color: var(--text-tertiary);
    text-transform: uppercase; letter-spacing: 0.09em;
    padding: 14px 10px 5px; font-weight: 600;
}

.ni {
    display: flex; align-items: center; gap: 9px;
    padding: 7px 10px; border-radius: 8px;
    cursor: pointer; color: var(--text-secondary); font-size: 13px;
    margin-bottom: 2px; text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
    position: relative;
}
.ni:hover { background: var(--surface-2); color: var(--text-primary); }
.ni.on    {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 500;
}
.ni.on i { color: var(--accent); opacity: 1; }
.ni i     { font-size: 15px; flex-shrink: 0; opacity: 0.7; }

.npill {
    margin-left: auto; font-size: 10px; color: var(--text-tertiary);
    background: var(--surface-2); padding: 1px 6px; border-radius: 10px;
}
.npill.alert { color: var(--accent); background: var(--accent-soft); }

.sfoot { padding: 10px 8px; border-top: 1px solid var(--border); flex-shrink: 0; }

.urow {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px; border-radius: 6px; cursor: pointer;
    width: 100%; background: none; border: none; text-align: left;
    font-family: var(--font-sans);
}
.urow:hover { background: var(--surface-2); }

/* User menu popover (Settings / Log out) */
.umenu-wrap { position: relative; }
.umenu {
    position: absolute; bottom: calc(100% + 6px); left: 0; right: 0;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; box-shadow: var(--shadow-lg);
    padding: 4px; z-index: 200;
}
.umenu[hidden] { display: none; }
.umenu-item {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 10px; border-radius: 6px;
    font-size: 12.5px; color: var(--text-secondary);
    text-decoration: none; cursor: pointer;
}
.umenu-item:hover, .umenu-item.on { background: var(--surface-2); color: var(--text-primary); }
.umenu-item i { font-size: 15px; }
.umenu-item-danger { color: var(--negative); }
.umenu-item-danger:hover { background: #fdecec; color: var(--negative); }

.av {
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--accent-soft); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 9px; font-weight: 600; color: var(--accent); flex-shrink: 0;
}
.uname { font-size: 11.5px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.urole { font-size: 10px; color: var(--text-tertiary); text-transform: capitalize; }

/* ── Sidebar backdrop ── */
.sidebar-backdrop { display: none; }
.sidebar-backdrop.is-visible {
    display: block; position: fixed; inset: 0; z-index: 99;
    background: rgba(0,0,0,0.35); -webkit-tap-highlight-color: transparent;
}

/* ── Main ── */
.main {
    flex: 1; display: flex; flex-direction: column;
    overflow: hidden; min-width: 0; margin-left: var(--sidebar-width);
}

/* ── Topbar ── */
.topbar {
    height: 56px; min-height: 56px;
    background: var(--bg); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 24px; gap: 10px;
    flex-shrink: 0; z-index: 50;
}
.pg-title { font-size: 15px; font-weight: 600; color: var(--text-primary); flex: 1; }

.mobile-nav-toggle {
    display: none; align-items: center; justify-content: center;
    width: 32px; height: 32px; border: none; background: none;
    color: var(--text-secondary); cursor: pointer; font-size: 18px; padding: 0;
    border-radius: 8px; flex-shrink: 0;
}
.mobile-nav-toggle:hover { background: var(--surface-2); }

/* ── Content area ── */
.content-area { flex: 1; overflow-y: auto; background: var(--bg); }

/* ── Buttons ── */
.tbtn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 12px; border-radius: 6px;
    font-size: 11.5px; font-weight: 500;
    cursor: pointer; border: none; font-family: var(--font-sans);
    transition: background 0.1s, color 0.1s; text-decoration: none;
}
.tbtn-ghost { background: var(--surface); color: var(--text-secondary); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.tbtn-ghost:hover { background: var(--surface-2); color: var(--text-primary); }
.tbtn-solid { background: var(--accent); color: #fff; }
.tbtn-solid:hover { background: var(--accent-hover); }

/* ── Topbar search ── */
.srch {
    display: flex; align-items: center; gap: 7px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 6px 12px; width: 220px;
}
.srch input { background: none; border: none; outline: none; font-size: 12px; color: var(--text-primary); width: 100%; font-family: var(--font-sans); }
.srch input::placeholder { color: var(--text-tertiary); }
.srch i { color: var(--text-tertiary); font-size: 13px; flex-shrink: 0; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 6px; font-size: 10px; font-weight: 500; }
.b-ok   { background: #ECFDF3; color: #16A34A; }
.b-pend { background: #FEF6E7; color: #D97706; }
.b-disc { background: #FEECEC; color: #DC2626; }
.b-gc   { background: var(--surface-2); color: var(--text-secondary); }
.dot { width: 5px; height: 5px; border-radius: 50%; display: inline-block; }
.d-ok   { background: #16A34A; }
.d-pend { background: #D97706; }
.d-disc { background: #DC2626; }

/* ── KPI cards ── */
.kpi-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 24px; margin-bottom: 24px; }
.kpi { background: var(--surface); border: none; border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kpi-lbl { font-size: 10px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.kpi-icon { font-size: 15px; color: var(--text-tertiary); }

/* ── Colored icon chip (KPI + alert cards) ── */
.icon-chip {
    width: 36px; height: 36px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px; flex-shrink: 0;
}
.chip-coral { background: var(--coral-soft); color: var(--coral); }
.chip-blue  { background: var(--blue-soft);  color: var(--blue); }
.chip-green { background: var(--green-soft);  color: var(--green); }
.chip-amber { background: var(--amber-soft);  color: var(--amber); }
.kpi-num { font-size: 26px; font-weight: 600; color: var(--text-primary); line-height: 1; margin-bottom: 6px; }
.kpi-delta { font-size: 11px; color: var(--text-secondary); display: flex; align-items: center; gap: 3px; }
.kpi-delta.pos { color: var(--positive); }
.kpi-delta.neg { color: var(--negative); }

/* ── Card ── */
.card { background: var(--surface); border: none; border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-ttl  { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.card-meta { font-size: 11px; color: var(--text-tertiary); }

/* ── Base table ── */
table { width: 100%; border-collapse: collapse; }
thead th {
    font-size: 10px; color: var(--text-tertiary); text-transform: uppercase;
    letter-spacing: 0.06em; font-weight: 600; padding: 10px 14px;
    text-align: left; border-bottom: 1px solid var(--border);
    white-space: nowrap; background: var(--surface);
}
tbody tr { border-bottom: 1px solid var(--border-subtle); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child { border-bottom: none; }
td { padding: 11px 14px; font-size: 12px; color: var(--text-secondary); vertical-align: middle; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
td.hi    { color: var(--text-primary); font-weight: 500; }
td.muted { color: var(--text-tertiary); }

/* ── Animations ── */
@keyframes fadeInUp { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Recon table responsive (unchanged from original) ── */
@media (max-width:1600px) {
    .recon-table th:nth-child(4),.recon-table td:nth-child(4),
    .recon-table th:nth-child(6),.recon-table td:nth-child(6),
    .recon-table th:nth-child(7),.recon-table td:nth-child(7) { display:none; }
}
@media (max-width:1200px) {
    .recon-table th:nth-child(11),.recon-table td:nth-child(11),
    .recon-table th:nth-child(15),.recon-table td:nth-child(15),
    .recon-table th:nth-child(18),.recon-table td:nth-child(18) { display:none; }
}
@media (max-width:900px) {
    .recon-table th:nth-child(3),.recon-table td:nth-child(3),
    .recon-table th:nth-child(10),.recon-table td:nth-child(10),
    .recon-table th:nth-child(16),.recon-table td:nth-child(16) { display:none; }
}

/* ── Mobile ── */
@media (max-width:768px) {
    body.nav-open { overflow:hidden; touch-action:none; }
    .sidebar { transform:translateX(-100%); transition:transform 0.25s ease; box-shadow:none; }
    .sidebar.open { transform:translateX(0); box-shadow:4px 0 20px rgba(0,0,0,0.5); }
    .main { margin-left:0; }
    .mobile-nav-toggle { display:flex; }
    .kpi-row { grid-template-columns:repeat(2,1fr); }
    .recon-table th:nth-child(9),.recon-table td:nth-child(9),
    .recon-table th:nth-child(12),.recon-table td:nth-child(12),
    .recon-table th:nth-child(13),.recon-table td:nth-child(13),
    .recon-table th:nth-child(19),.recon-table td:nth-child(19) { display:none; }
}
@media (max-width:480px) { .kpi-row { grid-template-columns:1fr; } }

/* ── Gift Cards ── */
.gc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 8px;
}

.gc-tile {
    background: transparent;
    border-radius: 10px;
    height: 214px;
    perspective: 1000px;
    cursor: default;
}
.gc-tile:hover .gc-tile-inner { border-color: rgba(255,255,255,0.1); }
.gc-tile.flipped .gc-tile-inner { transform: rotateY(180deg); }

.gc-tile-inner {
    position: relative;
    width: 100%; height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.4,0.2,0.2,1);
    border: 0.5px solid var(--border);
    border-radius: 10px;
    transition: transform 0.5s cubic-bezier(0.4,0.2,0.2,1), border-color 0.15s;
}

.gc-tile-front, .gc-tile-back {
    position: absolute; inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface);
}
.gc-tile-front {
    padding: 10px 12px;
    display: flex; flex-direction: column; gap: 6px;
}
.gc-tile-back {
    transform: rotateY(180deg);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 8px; padding: 16px;
}

.gc-tile-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.gc-brand-badge {
    width: 36px; height: 36px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600; color: #e8e8f0;
    flex-shrink: 0;
    text-transform: uppercase;
}

.gc-retailer { font-size: 12px; font-weight: 500; color: #c8c8d8; flex: 1; }
.gc-date     { font-size: 10px; color: #2a2a32; }

.gc-field-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.gc-field-lbl { font-size: 9px; color: #2a2a32; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 500; }
.gc-field-val {
    font-size: 12px; color: #888898;
    cursor: pointer;
    font-family: 'SF Mono', 'Fira Code', monospace;
    letter-spacing: 0.03em;
}
.gc-field-val:hover { color: #c8c8d8; }

.gc-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 2px;
}

.gc-status {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 7px; border-radius: 4px;
    font-size: 10px; font-weight: 500;
}
.gc-s-check    { background: rgba(200,130,30,0.15); color: #d4952a; }
.gc-s-avail    { background: rgba(74,124,89,0.15);  color: #4a9c69; }
.gc-s-redeemed { background: rgba(180,60,60,0.15);  color: #c05050; }

.gc-balance-edit {
    font-size: 11px; color: #44444e; cursor: pointer;
    background: none; border: none; padding: 0;
    font-family: var(--font-sans);
}
.gc-balance-edit:hover { color: #888898; }

.gc-icon-btn {
    background: none; border: none; padding: 0; cursor: pointer;
    color: #2a2a32; font-size: 11px; line-height: 1;
    display: inline-flex; align-items: center;
    transition: color 0.12s;
}
.gc-icon-btn:hover { color: #888898; }
.gc-icon-btn-danger:hover { color: #9c5050; }

.gc-upload-zone {
    border: 1px dashed rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: var(--surface);
}
.gc-upload-zone:hover,
.gc-upload-zone.dragover { border-color: rgba(255,255,255,0.22); background: rgba(255,255,255,0.02); }
.gc-upload-zone i { font-size: 28px; color: #2a2a32; margin-bottom: 8px; display: block; }
.gc-upload-zone p { font-size: 12px; color: #44444e; margin: 0; }

.gc-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.gc-form-group { display: flex; flex-direction: column; gap: 4px; }
.gc-form-group.full { grid-column: 1 / -1; }
.gc-lbl { font-size: 10px; color: #44444e; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; }
.gc-input {
    background: rgba(255,255,255,0.03);
    border: 0.5px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    padding: 7px 10px;
    font-size: 12px;
    color: #c8c8d8;
    font-family: var(--font-sans);
    outline: none;
    transition: border-color 0.15s;
}
.gc-input:focus { border-color: rgba(255,255,255,0.18); }
.gc-input::placeholder { color: #2a2a32; }
select.gc-input { cursor: pointer; }

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

.gc-search {
    display: flex; align-items: center; gap: 7px;
    background: rgba(255,255,255,0.03);
    border: 0.5px solid rgba(255,255,255,0.07);
    border-radius: 7px; padding: 5px 10px;
    flex: 1; min-width: 160px; max-width: 260px;
}
.gc-search input {
    background: none; border: none; outline: none;
    font-size: 12px; color: #888898; width: 100%;
    font-family: var(--font-sans);
}
.gc-search input::placeholder { color: #33333c; }
.gc-search i { color: #2a2a32; font-size: 13px; flex-shrink: 0; }

.gc-filter-sel {
    background: rgba(255,255,255,0.03);
    border: 0.5px solid rgba(255,255,255,0.07);
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 11px; color: #555560;
    font-family: var(--font-sans);
    outline: none; cursor: pointer;
}

.gc-preview-img {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 8px;
    border: 0.5px solid rgba(255,255,255,0.07);
    background: rgba(0,0,0,0.3);
}

.gc-raw-text {
    background: rgba(0,0,0,0.3);
    border: 0.5px solid rgba(255,255,255,0.06);
    border-radius: 6px;
    padding: 10px;
    font-size: 10px;
    color: #33333c;
    font-family: monospace;
    white-space: pre-wrap;
    max-height: 100px;
    overflow-y: auto;
    line-height: 1.5;
}

.gc-empty {
    text-align: center;
    padding: 48px 20px;
    color: #2a2a32;
    font-size: 12px;
}
.gc-empty i { font-size: 32px; display: block; margin-bottom: 10px; }
