/* =====================================================================
   Ankit Ornaments - application styles (mobile first)
   ===================================================================== */
:root {
    --navy: #172B4D;
    --navy-2: #1F3A66;
    --blue: #2563EB;
    --gold: #C6A15B;
    --gold-soft: #F6EFE0;
    --bg: #F5F7FA;
    --card: #FFFFFF;
    --text: #1F2937;
    --muted: #6B7280;
    --line: #E5E9F0;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(23, 43, 77, .05), 0 4px 16px rgba(23, 43, 77, .05);
    --bs-primary: #2563EB;
    --bs-primary-rgb: 37, 99, 235;
    --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --bs-body-color: #1F2937;
    --bs-body-bg: #F5F7FA;
    --bs-border-color: #E5E9F0;
    --bs-link-color: #2563EB;
    --bs-link-color-rgb: 37, 99, 235;
}

html, body { height: 100%; }
body { font-family: var(--bs-body-font-family); font-size: 15px; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
a { text-decoration: none; }
h1, h2, h3, h4, h5 { color: var(--navy); font-weight: 600; letter-spacing: -.01em; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.text-gold { color: #9A7A35 !important; }
.text-navy { color: var(--navy) !important; }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 248px; flex: 0 0 248px; background: var(--navy); color: #fff; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 14px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; padding: 6px 8px 18px; }
.brand strong { display: block; font-size: 16px; font-weight: 600; line-height: 1.2; }
.brand small { display: block; color: rgba(255, 255, 255, .55); font-size: 12px; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, #D9BB7C, var(--gold)); color: var(--navy); display: inline-flex; align-items: center; justify-content: center; font-size: 18px; flex: 0 0 auto; }
.brand-mark.lg { width: 56px; height: 56px; font-size: 26px; border-radius: 16px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.side-nav .nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: rgba(255, 255, 255, .72); font-weight: 500; font-size: 14.5px; }
.side-nav .nav-item i { font-size: 17px; width: 20px; text-align: center; }
.side-nav .nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.side-nav .nav-item.active { background: rgba(198, 161, 91, .18); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.side-nav .nav-item.active i { color: var(--gold); }
.side-foot { font-size: 12px; color: rgba(255, 255, 255, .4); padding: 12px 8px 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: 10px; height: 60px; padding: 0 16px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-title { flex: 1; min-width: 0; font-weight: 600; font-size: 17px; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rate-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px; background: var(--gold-soft); color: #7A5F24; font-size: 13px; white-space: nowrap; border: 1px solid #EADDBF; }
.rate-chip strong { font-weight: 600; }
.user-btn { display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent; color: var(--text); font-weight: 500; padding: 4px; border-radius: 999px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; }
.content { padding: 16px; padding-bottom: 96px; max-width: 1280px; width: 100%; margin: 0 auto; }

/* ---------- Bottom navigation (mobile) ---------- */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; display: grid; grid-template-columns: repeat(5, 1fr); background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 16px rgba(23, 43, 77, .06); }
.bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 60px; color: var(--muted); font-size: 11px; font-weight: 500; border: 0; background: transparent; }
.bottom-nav i { font-size: 20px; line-height: 1; }
.bottom-nav .active { color: var(--blue); }
.more-menu { height: auto !important; max-height: 80vh; border-radius: 18px 18px 0 0; }
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.more-grid .nav-item { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px; border-radius: 12px; background: var(--bg); color: var(--navy); font-size: 12.5px; font-weight: 500; text-align: center; }
.more-grid .nav-item i { font-size: 22px; color: var(--blue); }
.more-grid .nav-item.active { background: var(--gold-soft); }

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.page-head h1 { font-size: 20px; margin: 0; }
.page-head .sub { color: var(--muted); font-size: 13.5px; margin: 2px 0 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13.5px; margin-bottom: 8px; }

/* ---------- Cards ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--card); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); padding: 13px 16px; font-weight: 600; color: var(--navy); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-body { padding: 16px; }
.card-header .btn { margin: -4px 0; }

.stat { display: flex; align-items: center; gap: 12px; padding: 14px; height: 100%; color: inherit; }
a.stat:hover { border-color: #C9D4E5; }
.stat-icon { width: 42px; height: 42px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 19px; flex: 0 0 auto; }
.stat-label { color: var(--muted); font-size: 12.5px; font-weight: 500; line-height: 1.2; }
.stat-value { font-size: 19px; font-weight: 700; color: var(--navy); line-height: 1.25; font-variant-numeric: tabular-nums; word-break: break-word; }
.tone-blue { background: #E8EFFD; color: var(--blue); }
.tone-gold { background: var(--gold-soft); color: #9A7A35; }
.tone-green { background: #E3F5EC; color: #15803D; }
.tone-amber { background: #FDF1DC; color: #B45309; }
.tone-red { background: #FDE8E8; color: #B91C1C; }
.tone-navy { background: #E6EAF1; color: var(--navy); }

.rate-card { background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%); color: #fff; border: 0; }
.rate-card .lbl { color: rgba(255, 255, 255, .65); font-size: 12.5px; }
.rate-card .big { font-size: 28px; font-weight: 700; color: #fff; line-height: 1.15; font-variant-numeric: tabular-nums; }
.rate-card .big small { font-size: 13px; font-weight: 500; color: rgba(255, 255, 255, .6); }
.rate-card .karat { background: rgba(255, 255, 255, .08); border-radius: 10px; padding: 8px 12px; }
.rate-card .karat b { display: block; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rate-card .karat span { font-size: 12px; color: var(--gold); font-weight: 600; }
.rate-card .meta { font-size: 12.5px; color: rgba(255, 255, 255, .65); }
.rate-card .btn-gold { background: var(--gold); color: var(--navy); border: 0; font-weight: 600; }

/* ---------- Detail lists ---------- */
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 0; }
.kv > div { min-width: 0; }
.kv dt { font-size: 12px; font-weight: 500; color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; word-break: break-word; }
.sum-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.sum-row:last-child { border-bottom: 0; }
.sum-row.total { font-weight: 700; color: var(--navy); font-size: 16px; border-top: 1px solid var(--line); border-bottom: 0; margin-top: 4px; padding-top: 10px; }

/* ---------- Forms ---------- */
.form-label { font-weight: 500; font-size: 13.5px; margin-bottom: 5px; color: #374151; }
.form-control, .form-select, .input-group-text { min-height: 44px; border-radius: 10px; border-color: #D5DBE5; font-size: 15px; }
.input-group > .form-control, .input-group > .input-group-text { border-radius: 10px; }
.input-group-text { background: #F3F5F9; color: var(--muted); font-size: 13.5px; }
.form-control:focus, .form-select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.form-section { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 6px 0 -2px; }
.calc-box { background: var(--gold-soft); border: 1px solid #EADDBF; border-radius: 12px; padding: 12px 14px; }
.calc-box .lbl { font-size: 12px; color: #7A5F24; font-weight: 500; }
.calc-box .val { font-size: 20px; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.calc-box .hint { font-size: 12px; color: #7A5F24; }
.rate-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.rate-pills button { border: 1px solid #EADDBF; background: var(--gold-soft); color: #7A5F24; border-radius: 999px; padding: 3px 10px; font-size: 12.5px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

.btn { border-radius: 10px; font-weight: 500; padding: .5rem .95rem; }
.btn-sm { border-radius: 8px; padding: .3rem .65rem; }
.btn-primary { background: var(--blue); border-color: var(--blue); }
.btn-primary:hover, .btn-primary:focus { background: #1D4ED8; border-color: #1D4ED8; }
.btn-navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-2); color: #fff; }
.btn-light { background: #fff; border-color: #D5DBE5; color: var(--text); }
.btn-light:hover { background: #F3F5F9; border-color: #C9D4E5; }

/* Customer picker */
.picker { position: relative; }
.picker-results { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin-top: 4px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(23, 43, 77, .14); max-height: 260px; overflow-y: auto; display: none; }
.picker-results.open { display: block; }
.picker-results button { display: block; width: 100%; text-align: left; border: 0; background: #fff; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.picker-results button:hover, .picker-results button:focus { background: #F3F6FC; }
.picker-results button small { color: var(--muted); display: block; }
.picker-results .empty { padding: 12px 14px; color: var(--muted); font-size: 13.5px; }
.picker-chosen { display: none; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; padding: 6px 8px 6px 14px; border: 1px solid #C9D7F5; border-radius: 10px; background: #F3F6FD; }
.picker.has-value .picker-chosen { display: flex; }
.picker.has-value .picker-search { display: none; }
.picker-chosen small { color: var(--muted); }

/* ---------- Badges ---------- */
.badge { font-weight: 600; font-size: 11.5px; padding: .38em .7em; border-radius: 999px; }
.badge-soft-warning { background: #FDF1DC; color: #B45309; }
.badge-soft-info { background: #E0F2FE; color: #0369A1; }
.badge-soft-primary { background: #E8EFFD; color: #1D4ED8; }
.badge-soft-success { background: #E3F5EC; color: #15803D; }
.badge-soft-secondary { background: #ECEFF3; color: #4B5563; }
.badge-soft-danger { background: #FDE8E8; color: #B91C1C; }

/* ---------- Tables ---------- */
.table { margin: 0; --bs-table-bg: transparent; }
.table > thead th { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #F8FAFC; border-bottom: 1px solid var(--line); padding: 10px 14px; white-space: nowrap; }
.table > tbody td { padding: 12px 14px; vertical-align: middle; border-color: var(--line); }
.table > tfoot td { padding: 12px 14px; font-weight: 700; color: var(--navy); background: #F8FAFC; border-top: 2px solid var(--line); }
.table > tbody tr:last-child td { border-bottom: 0; }
.table .text-end { font-variant-numeric: tabular-nums; }
.table a.row-link { font-weight: 600; color: var(--navy); }
.table tr.is-void td { color: #9CA3AF; text-decoration: line-through; }
.table tr.is-void td.no-strike { text-decoration: none; }
.table-wrap { overflow-x: auto; }
.empty-state { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty-state i { font-size: 34px; color: #C5CCD8; display: block; margin-bottom: 8px; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.filters .f { flex: 1 1 150px; min-width: 0; }
.filters .f-wide { flex: 2 1 220px; }
.filters .f-btn { flex: 0 0 auto; }
.chip-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.chip-tabs::-webkit-scrollbar { display: none; }
.chip-tabs a { flex: 0 0 auto; padding: 7px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--text); font-size: 13.5px; font-weight: 500; }
.chip-tabs a.active { background: var(--navy); border-color: var(--navy); color: #fff; }

.nav-tabs { border-bottom: 1px solid var(--line); gap: 4px; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tabs .nav-link { border: 0; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; white-space: nowrap; padding: 10px 14px; }
.nav-tabs .nav-link.active { color: var(--blue); border-bottom-color: var(--blue); background: transparent; }

.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); color: inherit; }
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { background: #F8FAFC; }
.list-row .t { font-weight: 600; color: var(--navy); }
.list-row .s { font-size: 12.5px; color: var(--muted); }
.list-row .r { text-align: right; white-space: nowrap; }

.report-tile { display: flex; gap: 12px; align-items: flex-start; padding: 14px; height: 100%; color: inherit; }
.report-tile:hover { border-color: #C9D4E5; }
.report-tile .t { font-weight: 600; color: var(--navy); }
.report-tile .s { font-size: 12.5px; color: var(--muted); }

.pagination .page-link { border-radius: 8px; margin: 0 2px; border-color: var(--line); color: var(--text); }
.pagination .active .page-link { background: var(--navy); border-color: var(--navy); color: #fff; }

/* ---------- Guest (login / install) ---------- */
body.guest { background: linear-gradient(160deg, var(--navy) 0%, #0F1E38 100%); }
.guest-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.guest-card { width: 100%; max-width: 420px; background: #fff; border-radius: 20px; padding: 28px 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.guest-brand { text-align: center; margin-bottom: 20px; }
.guest-brand h1 { font-size: 22px; margin: 12px 0 2px; }
.guest-brand p { color: var(--muted); margin: 0; font-size: 13.5px; }
.guest-foot { color: rgba(255, 255, 255, .45); font-size: 12.5px; margin-top: 18px; }

/* ---------- Desktop ---------- */
@media (min-width: 992px) {
    .content { padding: 24px 28px 40px; }
    .topbar { padding: 0 28px; height: 64px; }
    .page-head h1 { font-size: 22px; }
    .kv { grid-template-columns: repeat(3, 1fr); }
    .kv.cols-4 { grid-template-columns: repeat(4, 1fr); }
    .stat-value { font-size: 21px; }
}

/* ---------- Mobile: tables become readable cards ---------- */
@media (max-width: 767.98px) {
    .table-stack thead, .table-stack tfoot td:empty { display: none; }
    .table-stack, .table-stack tbody, .table-stack tfoot, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tbody tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
    .table-stack tbody tr:last-child { border-bottom: 0; }
    .table-stack tbody td { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 3px 0; border: 0; text-align: right; }
    .table-stack tbody td::before { content: attr(data-label); flex: 0 0 auto; color: var(--muted); font-size: 12.5px; font-weight: 500; text-align: left; }
    .table-stack tbody td[data-label=""]::before, .table-stack tbody td:not([data-label])::before { display: none; }
    .table-stack tbody td.cell-title { font-size: 15.5px; font-weight: 600; padding-bottom: 5px; text-align: left; justify-content: flex-start; }
    .table-stack tbody td.cell-title::before { display: none; }
    .table-stack tbody td.cell-actions { justify-content: flex-end; padding-top: 8px; }
    .table-stack tbody td.cell-actions::before { display: none; }
    .table-stack tbody td:empty { display: none; }
    .table-stack tfoot tr { padding: 10px 14px; background: #F8FAFC; border-top: 2px solid var(--line); }
    .table-stack tfoot td { display: flex; justify-content: space-between; gap: 14px; padding: 3px 0; border: 0; background: transparent; text-align: right; }
    .table-stack tfoot td::before { content: attr(data-label); color: var(--muted); font-weight: 500; font-size: 12.5px; }
    .table-wrap { overflow-x: visible; }
    .page-actions .btn { flex: 1 1 auto; }
    .form-actions .btn { flex: 1 1 100%; min-height: 48px; font-size: 16px; }
    .rate-chip span { font-size: 12px; }
    .rate-card .big { font-size: 24px; }
    .btn { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
    .btn-sm { min-height: 34px; }
}
@media (max-width: 380px) {
    .rate-chip { padding: 6px 8px; }
    .rate-chip i { display: none; }
    .stat { padding: 12px 10px; gap: 9px; }
    .stat-icon { width: 36px; height: 36px; font-size: 16px; }
    .stat-value { font-size: 16.5px; }
}
