/* ============================================================
   SakthiPro - Design System
   Primary #2563EB | Dark #1E40AF | Background #F8FAFC
   Cards #FFFFFF | Inter | Radius 16px
   ============================================================ */

:root {
  --primary: #2563EB;
  --primary-dark: #1E40AF;
  --primary-50: #EFF6FF;
  --primary-100: #DBEAFE;
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --text: #0F172A;
  --text-muted: #475569;
  --text-soft: #94A3B8;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --success: #16A34A;
  --success-bg: #DCFCE7;
  --warning: #D97706;
  --warning-bg: #FEF3C7;
  --danger: #DC2626;
  --danger-bg: #FEE2E2;
  --info: #0891B2;
  --info-bg: #CFFAFE;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
  --sidebar-w: 264px;
  --header-h: 68px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }

/* ---------- App Shell ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--primary-dark);
  background: linear-gradient(180deg, var(--primary-dark) 0%, #1E3A8A 100%);
  color: #E2E8F0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform .25s ease;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 22px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: .3px;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand .logo {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: transparent;
  border-radius: 12px;
  color: #fff;
  flex: none;
}
.sidebar .brand .logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 10px; }
.sidebar .brand small { display:block; font-size: 11px; font-weight: 500; color:#BFDBFE; letter-spacing: .5px; }

.nav { padding: 14px 12px; overflow-y: auto; flex: 1; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: #93C5FD; padding: 16px 12px 8px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  color: #DBEAFE;
  font-weight: 500;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background .18s ease, color .18s ease;
}
.nav a svg { width: 20px; height: 20px; flex: none; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }

.sidebar .foot {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px;
  color: #BFDBFE;
}

/* ---------- Main ---------- */
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }

.topbar {
  height: var(--header-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar .page-title { font-size: 18px; font-weight: 700; }
.topbar .page-sub { font-size: 12px; color: var(--text-muted); }

.topbar-right { display: flex; align-items: center; gap: 18px; }
.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .18s ease, color .18s ease;
  position: relative;
  background: transparent;
  border: 1px solid transparent;
}
.icon-btn:hover { background: var(--bg); color: var(--primary); border-color: var(--border); }
.icon-btn svg { width: 20px; height: 20px; }
.badge-count {
  position: absolute; top: 4px; right: 4px;
  background: var(--danger); color:#fff;
  font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: grid; place-items: center; padding: 0 4px;
}

.user-chip { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 700; flex: none;
}
.user-chip .meta { line-height: 1.15; }
.user-chip .meta .name { font-weight: 600; font-size: 13px; }
.user-chip .meta .role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }

.content { padding: 28px; max-width: 1400px; }

/* ---------- Mobile menu toggle ---------- */
.menu-toggle { display: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.card-body { padding: 22px; }
.card-grid { display: grid; gap: 20px; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat .ic {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; margin-bottom: 14px;
  background: var(--primary-50); color: var(--primary);
}
.stat .ic svg { width: 22px; height: 22px; }
.stat .label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.stat .value { font-size: 26px; font-weight: 800; margin-top: 4px; letter-spacing: -.5px; }
.stat.accent-gold .ic { background:#FEF3C7; color:#B45309; }
.stat.accent-green .ic { background: var(--success-bg); color: var(--success); }
.stat.accent-red .ic { background: var(--danger-bg); color: var(--danger); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 10px 18px; border-radius: 12px; border: 1px solid transparent;
  cursor: pointer; transition: background .18s ease, color .18s ease, box-shadow .18s ease, border-color .18s ease;
  line-height: 1; white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--primary-50); color: var(--primary-dark); }
.btn-secondary:hover { background: var(--primary-100); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #B91C1C; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: var(--text); }
.field .hint { font-size: 12px; color: var(--text-soft); }
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=search], select, textarea {
  font-family: inherit; font-size: 14px;
  padding: 11px 14px; border: 1px solid var(--border-strong);
  border-radius: 12px; background: #fff; color: var(--text);
  width: 100%; transition: border-color .18s ease, box-shadow .18s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-100);
}
textarea { resize: vertical; min-height: 90px; }
.field .err { color: var(--danger); font-size: 12px; }

.search-bar { position: relative; max-width: 360px; }
.search-bar svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-soft); }
.search-bar input { padding-left: 42px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
table.data th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); font-weight: 700; padding: 14px 18px; border-bottom: 1px solid var(--border);
  background: #FCFDFE; white-space: nowrap;
}
table.data td { padding: 14px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr { transition: background .15s ease; }
table.data tbody tr:hover { background: var(--bg); }
table.data tbody tr:last-child td { border-bottom: none; }
.sub { font-size: 12px; color: var(--text-muted); }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 4px 11px; border-radius: 999px;
}
.badge::before { content:''; width:7px; height:7px; border-radius:50%; background: currentColor; }
.badge-active   { background: var(--success-bg); color: var(--success); }
.badge-pending  { background: var(--warning-bg); color: var(--warning); }
.badge-closed   { background: #E2E8F0; color: #475569; }
.badge-overdue  { background: var(--danger-bg); color: var(--danger); }
.badge-rejected { background: var(--danger-bg); color: var(--danger); }
.badge-gold     { background: #FEF3C7; color: #B45309; }
.badge-cash     { background: var(--primary-50); color: var(--primary); }

/* ---------- Alerts ---------- */
.alert { padding: 13px 16px; border-radius: 12px; margin-bottom: 18px; font-weight: 500; }
.alert-success { background: var(--success-bg); color: #166534; }
.alert-error { background: var(--danger-bg); color: #991B1B; }

/* ---------- Avatar / photo ---------- */
.photo {
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--primary-50); object-fit: cover; border: 3px solid #fff; box-shadow: var(--shadow-sm);
}
.photo-square { width: 120px; height: 120px; border-radius: var(--radius-sm); }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content:''; position:absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline li { position: relative; padding-bottom: 20px; }
.timeline li::before {
  content:''; position: absolute; left: -23px; top: 3px;
  width: 14px; height: 14px; border-radius: 50%; background: var(--primary); border: 3px solid #fff; box-shadow: var(--shadow-sm);
}
.timeline .t-time { font-size: 12px; color: var(--text-soft); }
.timeline .t-title { font-weight: 600; }

/* ---------- Profile header ---------- */
.profile-head { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.profile-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 14px 28px; margin-top: 18px; }
.profile-meta .k { font-size: 12px; color: var(--text-muted); }
.profile-meta .v { font-weight: 600; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); padding: 0 22px; }
.tabs button {
  background: none; border: none; font-family: inherit; font-size: 14px; font-weight: 600;
  color: var(--text-muted); padding: 14px 14px; cursor: pointer; border-bottom: 2px solid transparent;
  transition: color .15s ease;
}
.tabs button:hover { color: var(--primary); }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; padding: 22px; }
.tab-panel.active { display: block; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); backdrop-filter: blur(2px);
  display: none; align-items: flex-start; justify-content: center; z-index: 100; padding: 60px 16px; overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius); width: 100%; max-width: 560px; box-shadow: var(--shadow-lg);
  animation: pop .2s ease;
}
@keyframes pop { from { transform: translateY(12px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero {
  background: linear-gradient(150deg, var(--primary-dark) 0%, #2563EB 100%);
  color: #fff; padding: 60px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-hero::after {
  content:''; position: absolute; width: 420px; height: 420px; border-radius: 50%;
  background: rgba(255,255,255,.08); bottom: -160px; right: -120px;
}
.login-hero .hero-logo { display: flex; align-items: center; gap: 14px; font-size: 24px; font-weight: 800; position: relative; z-index: 1; }
.login-hero .logo { width: 52px; height: 52px; border-radius: 14px; background: transparent; display: grid; place-items: center; }
.login-hero .logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 14px; }
.login-hero h1 { font-size: 38px; line-height: 1.2; position: relative; z-index: 1; max-width: 520px; }
.login-hero p { color: #BFDBFE; position: relative; z-index: 1; max-width: 460px; }
.login-card { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-box { width: 100%; max-width: 380px; }
.login-box h2 { font-size: 24px; margin: 0 0 6px; }
.pin-input {
  display: flex; gap: 12px; justify-content: space-between; margin: 6px 0 4px;
}
.pin-input input {
  width: 56px; height: 64px; text-align: center; font-size: 26px; font-weight: 700;
  border: 1px solid var(--border-strong); border-radius: 14px;
}
.pin-input input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }

/* ---------- Misc utilities ---------- */
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.mt-0{margin-top:0}.mt-1{margin-top:8px}.mt-2{margin-top:16px}.mt-3{margin-top:24px}.mt-4{margin-top:32px}
.mb-1{margin-bottom:8px}.mb-2{margin-bottom:16px}.mb-3{margin-bottom:24px}
.text-muted{color:var(--text-muted)}.text-sm{font-size:12px}.fw-600{font-weight:600}.right{text-align:right}
.empty { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty svg { width: 48px; height: 48px; color: var(--text-soft); margin-bottom: 12px; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 16px; }
.doc-card { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background:#fff; }
.doc-card .thumb { height: 110px; background: var(--bg); display: grid; place-items: center; color: var(--text-soft); }
.doc-card .thumb img { width:100%; height:100%; object-fit: cover; }
.doc-card .thumb svg { width: 36px; height: 36px; }
.doc-card .meta { padding: 10px 12px; }
.doc-card .meta .t { font-size: 12px; font-weight: 600; }
.doc-card .acts { display: flex; gap: 6px; padding: 0 12px 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .menu-toggle { display: grid; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .content { padding: 18px; }
}
.section-title { margin: 0; font-size: 15px; font-weight: 700; color: var(--text); }
.period-grid { grid-template-columns: repeat(4, 1fr); }
.report-card .card-body { display: flex; flex-direction: column; gap: 12px; }
.rp-metric { display: flex; align-items: center; gap: 10px; }
.rp-metric .ic { width: 32px; height: 32px; border-radius: 8px; background: var(--primary-50); color: var(--primary); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.rp-metric .k { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.rp-metric .v { font-size: 16px; font-weight: 700; line-height: 1.15; }
.rp-metric .hint { font-size: 11px; color: var(--text-muted); }
.btn.full { width: 100%; justify-content: center; margin-top: 2px; }
@media (max-width: 1100px) { .period-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px)  { .period-grid { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Gold Valuation table ---------- */
.gold-table { width: 100%; min-width: 920px; }
.gold-table th { font-size: 12px; white-space: nowrap; }
.gold-table td { padding: 8px 10px; }
.gold-table td input { width: 100%; min-width: 80px; }
.gold-table .gi-market-cell { white-space: nowrap; font-weight: 600; color: var(--text); }
.gold-table .gi-del { padding: 6px 8px; }

.upload-block { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--border); }
.upload-label { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.upload-label .sub { font-weight: 400; }
.thumb-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.thumb-grid .thumb { width: 96px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg); }
.thumb-grid .thumb img { width: 100%; height: 72px; object-fit: cover; display: block; }
.thumb-grid .thumb span { display: block; padding: 4px 6px; font-size: 10px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
