/* ==========================================================================
   Tola — Training & Course Management
   Modern card-based UI · subtle colours · responsive
   ========================================================================== */

:root {
  --bg:         #f6f7fb;
  --surface:    #ffffff;
  --text:       #1f2437;
  --muted:      #69718a;
  --border:     #e7e9f2;
  --border-soft:#eef0f7;

  --primary:    #4f46e5;
  --primary-2:  #7c3aed;
  --primary-soft:#eef0fe;
  --green:      #059669;
  --green-2:    #10b981;
  --green-soft: #e7f8f1;
  --amber:      #b45309;
  --amber-soft: #fdf3e2;
  --red:        #dc2626;
  --red-soft:   #fdecec;
  --violet:     #7c3aed;
  --violet-soft:#f3eefe;

  --radius:     16px;
  --radius-sm:  10px;
  --shadow-sm:  0 1px 2px rgba(23, 26, 43, .05);
  --shadow-md:  0 6px 24px rgba(23, 26, 43, .07);
  --font:       'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.18rem; }
h3 { font-size: 1.02rem; }
p  { margin: 0 0 1em; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 22px; }
.main { min-height: calc(100vh - 210px); padding: 28px 0 60px; }
.muted  { color: var(--muted); }
.small  { font-size: .84rem; }
.ic     { width: 20px; height: 20px; flex: none; vertical-align: -.35em; }
.ic-sm  { width: 15px; height: 15px; }

.inline-form { display: inline; }

/* ------------------------------------------------------------- navbar -- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner { display: flex; align-items: center; gap: 18px; min-height: 64px; }

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.18rem; color: var(--text); letter-spacing: -.02em; }
.brand-name { font-size: 1.15rem; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; box-shadow: 0 4px 12px rgba(79, 70, 229, .35);
}
.brand-mark .ic { width: 19px; height: 19px; }

.nav-links { display: flex; align-items: center; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.nav-spacer { flex: 1; }
.nav-link {
  padding: 8px 14px; border-radius: 10px; color: var(--muted); font-weight: 500; font-size: .93rem;
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--text); background: var(--border-soft); }
.nav-link.active { color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.nav-badge {
  background: var(--red); color: #fff; font-size: .68rem; font-weight: 700;
  padding: 1px 7px; border-radius: 99px; vertical-align: 2px;
}
.nav-user { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 99px; background: var(--border-soft); }
.nav-user-name { font-size: .88rem; font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; font-size: .8rem; font-weight: 700;
}
.avatar-lg { width: 42px; height: 42px; font-size: 1rem; }

.nav-toggle { display: none; margin-left: auto; background: none; border: 0; color: var(--text); padding: 8px; cursor: pointer; border-radius: 10px; }
.nav-toggle:hover { background: var(--border-soft); }

/* ------------------------------------------------------------ buttons -- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-family: inherit; font-size: .92rem; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: transform .12s, box-shadow .15s, background .15s, border-color .15s, color .15s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 4px 14px rgba(79, 70, 229, .3); }
.btn-primary:hover { box-shadow: 0 6px 18px rgba(79, 70, 229, .4); transform: translateY(-1px); }

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

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--border-soft); color: var(--text); }

.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-soft); color: var(--red); }

.btn-join {
  background: linear-gradient(135deg, var(--green), var(--green-2));
  color: #fff; font-weight: 700; letter-spacing: .01em;
  box-shadow: 0 4px 14px rgba(5, 150, 105, .35);
}
.btn-join:hover { box-shadow: 0 6px 20px rgba(5, 150, 105, .45); transform: translateY(-1px); }

.btn-disabled { background: var(--border-soft); color: var(--muted); cursor: default; }
.btn-disabled:hover { transform: none; }

.btn-sm { padding: 6px 12px; font-size: .84rem; border-radius: 9px; }
.btn-lg { padding: 13px 26px; font-size: 1rem; border-radius: 12px; }
.btn-block { width: 100%; }

/* ------------------------------------------------------------- flash --- */
.flash {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: 12px; margin-bottom: 18px;
  font-size: .92rem; font-weight: 500; border: 1px solid;
}
.flash-success { background: var(--green-soft); border-color: #c4ecd9; color: #047857; }
.flash-error   { background: var(--red-soft);   border-color: #f6caca; color: #b91c1c; }
.flash-info    { background: var(--primary-soft); border-color: #d8dbfb; color: var(--primary); }

/* ------------------------------------------------------ page headers --- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.page-sub { color: var(--muted); margin: 2px 0 0; font-size: .95rem; }

.crumbs { margin: 0 0 14px; font-size: .88rem; }
.crumbs a { color: var(--muted); font-weight: 500; }
.crumbs a:hover { color: var(--primary); }
.crumb-sep { color: var(--border); margin: 0 8px; }

.section { margin-bottom: 38px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.section-head h2 { display: flex; align-items: center; gap: 10px; margin: 0; }
.section-head h2 .ic { color: var(--primary); }

/* -------------------------------------------------------------- cards -- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-title { display: flex; align-items: center; gap: 8px; padding: 16px 18px 0; margin: 0; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 20px;
}

/* -------------------------------------------------------- stat cards --- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; margin-bottom: 36px; }
.stat-card {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow-sm);
  color: var(--text); transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card strong { display: block; font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.stat-card span:last-child { color: var(--muted); font-size: .88rem; font-weight: 500; }

/* ----------------------------------------------------- course cards ---- */
.course-card { display: flex; flex-direction: column; overflow: hidden; color: var(--text); transition: transform .18s, box-shadow .18s; }
.course-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
a.course-card { color: var(--text); }

.course-thumb { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: var(--border-soft); display: block; }
.course-thumb img { width: 100%; height: 100%; object-fit: cover; }
.badge-enrolled { position: absolute; top: 10px; right: 10px; box-shadow: var(--shadow-sm); }

.thumb-fallback {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 800; letter-spacing: .04em; color: #fff;
}
.thumb-fallback.lg { font-size: 2.6rem; }
.thumb-fallback.mini { width: 44px; height: 32px; border-radius: 8px; font-size: .8rem; flex: none; }

.t-0 { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.t-1 { background: linear-gradient(135deg, #0ea5e9, #6366f1); }
.t-2 { background: linear-gradient(135deg, #10b981, #0ea5e9); }
.t-3 { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.t-4 { background: linear-gradient(135deg, #ec4899, #8b5cf6); }

.course-body { display: flex; flex-direction: column; gap: 8px; padding: 16px 18px 18px; flex: 1; }
.course-title { margin: 0; font-size: 1.04rem; }
.course-title a { color: var(--text); }
.course-title a:hover { color: var(--primary); }
.course-desc { color: var(--muted); font-size: .89rem; margin: 0; flex: 1; }
.course-meta { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: .82rem; flex-wrap: wrap; }
.course-meta .ic-sm { vertical-align: -.25em; margin-right: 2px; color: var(--primary); }
.course-go { margin-left: auto; color: var(--primary); font-weight: 600; font-size: .85rem; }

/* -------------------------------------------------------- course hero -- */
.course-hero { display: flex; gap: 26px; padding: 26px; margin-bottom: 34px; }
.course-hero-thumb { width: 300px; flex: none; aspect-ratio: 16 / 10; border-radius: 12px; overflow: hidden; background: var(--border-soft); }
.course-hero-thumb img { width: 100%; height: 100%; object-fit: cover; }
.course-hero-body { flex: 1; min-width: 0; }
.course-hero-desc { color: var(--muted); margin: 6px 0 14px; }
.course-hero-actions { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--border-soft); border-radius: 99px;
  padding: 5px 12px; font-size: .82rem; font-weight: 500; color: var(--muted);
}
.chip .ic-sm { color: var(--primary); }

/* ------------------------------------------------------ session cards -- */
.session-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }

.session-card { display: flex; flex-direction: column; gap: 9px; padding: 18px; }
.session-live { border-color: #bfe8d6; background: linear-gradient(180deg, #f4fcf8, #ffffff); box-shadow: 0 6px 24px rgba(5, 150, 105, .12); }

.session-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.session-rel { color: var(--muted); font-size: .8rem; font-weight: 500; }
.session-title { margin: 2px 0 0; font-size: 1.05rem; }
.session-course { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .84rem; margin: 0; }
.session-course .ic-sm { color: var(--primary); }
.session-meta { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .85rem; }
.session-card .btn-join, .session-card .btn-disabled { margin-top: auto; }

/* ------------------------------------------------------------- badges -- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .74rem; font-weight: 700; letter-spacing: .02em;
  padding: 4px 10px; border-radius: 99px; text-transform: uppercase;
}
.badge-lg { font-size: .86rem; padding: 8px 14px; }
.badge-live     { background: var(--green-soft); color: #047857; }
.badge-upcoming { background: var(--primary-soft); color: var(--primary); }
.badge-ended    { background: var(--border-soft); color: var(--muted); }
.badge-enrolled { background: var(--green-soft); color: #047857; text-transform: none; }
.badge-soft     { background: var(--primary-soft); color: var(--primary); text-transform: none; font-weight: 600; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green-2); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .45); }
  50%      { box-shadow: 0 0 0 5px rgba(16, 185, 129, 0); }
}

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--primary-soft); color: var(--primary);
  font-size: .82rem; font-weight: 600;
  padding: 6px 14px; border-radius: 99px; margin-bottom: 18px;
}
.pill .ic { width: 15px; height: 15px; }
.pill-live { background: var(--green-soft); color: #047857; }

/* ------------------------------------------------------------ lessons -- */
.lesson-list { display: flex; flex-direction: column; gap: 12px; }

.lesson-card summary {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px; cursor: pointer; list-style: none;
}
.lesson-card summary::-webkit-details-marker { display: none; }
.lesson-card summary:hover { background: #fafbfe; }
.lesson-card[open] summary { border-bottom: 1px solid var(--border-soft); }

.lesson-num {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
  font-weight: 700; font-size: .9rem;
}
.lesson-title { font-weight: 600; flex: 1; min-width: 0; }
.lesson-chev { color: var(--muted); transition: transform .2s; }
.lesson-card[open] .lesson-chev { transform: rotate(180deg); }

.lesson-body { padding: 18px; }
.lesson-content { color: #3c425c; white-space: normal; }
.lesson-content + *, .video-embed + .lesson-content { margin-top: 12px; }

.lesson-static { padding: 0; }
.lesson-row { display: flex; align-items: center; gap: 14px; padding: 14px 18px; }
.lesson-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lesson-hint { font-size: .82rem; display: flex; align-items: center; gap: 4px; }

.video-embed { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #14161f; margin-bottom: 4px; }
.video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.leave-form { margin-top: 22px; text-align: right; }

/* ------------------------------------------------------------- tables -- */
.table-card { overflow: hidden; }
.table-card > .table { margin: 10px 0 0; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th {
  text-align: left; padding: 12px 18px;
  font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); border-bottom: 1px solid var(--border);
}
.table td { padding: 13px 18px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfe; }
.th-actions { width: 1%; white-space: nowrap; }
.cell-actions { white-space: nowrap; text-align: right; display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
.table td.cell-actions { display: table-cell; }
.cell-actions .inline-form { display: inline-block; }

.cell-with-thumb { display: flex; align-items: center; gap: 12px; }
.thumb-mini { width: 52px; height: 38px; object-fit: cover; border-radius: 8px; flex: none; border: 1px solid var(--border); }
.cell-with-user { display: flex; align-items: center; gap: 12px; }
.link-muted { color: var(--muted); font-size: .84rem; }
.link-muted:hover { color: var(--primary); }

/* -------------------------------------------------------- empty state -- */
.empty {
  text-align: center; padding: 52px 24px;
  background: var(--surface); border: 1.5px dashed var(--border);
  border-radius: var(--radius);
}
.empty-ic { width: 42px; height: 42px; color: #c3c8da; margin-bottom: 10px; }
.empty h3 { margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 420px; margin: 0 auto 18px; }

/* -------------------------------------------------------------- forms -- */
.form-card { max-width: 660px; padding: 28px; }

.field { margin-bottom: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-small { max-width: 130px; }

.field label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 7px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 11px 14px;
  font-family: inherit; font-size: .95rem; color: var(--text);
  background: #fbfbfe; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field textarea { resize: vertical; min-height: 110px; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; background: #fff; border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, .12);
}
.field input[type=file] { padding: 9px; background: #fff; }
.field input[type=file]::file-selector-button {
  font-family: inherit; font-weight: 600; font-size: .85rem;
  border: 1px solid var(--border); background: var(--border-soft);
  color: var(--text); padding: 7px 14px; border-radius: 8px; cursor: pointer; margin-right: 12px;
}
.field input[type=file]::file-selector-button:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }

.field-hint { font-size: .8rem; color: var(--muted); margin: 7px 0 0; }
.field-error { font-size: .82rem; color: var(--red); margin: 7px 0 0; font-weight: 500; }
.form-actions { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }

.thumb-preview { margin-top: 12px; }
.thumb-preview img { width: 220px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }

/* ----------------------------------------------------------- landing --- */
.hero { padding: 68px 0 30px; text-align: center; }
.hero-copy { max-width: 680px; margin: 0 auto; }
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.3rem); font-weight: 800; letter-spacing: -.03em; margin-bottom: 18px; }
.grad-text { background: linear-gradient(135deg, var(--primary), var(--primary-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { color: var(--muted); font-size: 1.1rem; max-width: 540px; margin: 0 auto 28px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 40px; }

.hero-stats { display: flex; justify-content: center; gap: 48px; flex-wrap: wrap; }
.hero-stats div { display: flex; flex-direction: column; }
.hero-stats strong { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.hero-stats span { color: var(--muted); font-size: .86rem; }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; padding: 30px 0 60px; }
.feature-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow-sm); }
.feature-card h3 { margin: 14px 0 6px; }
.feature-card p { color: var(--muted); font-size: .92rem; margin: 0; }
.feature-ic {
  width: 46px; height: 46px; border-radius: 13px;
  display: inline-flex; align-items: center; justify-content: center;
}
.feature-ic .ic { width: 22px; height: 22px; }
.ic-indigo { background: var(--primary-soft); color: var(--primary); }
.ic-green  { background: var(--green-soft);  color: var(--green); }
.ic-amber  { background: var(--amber-soft);  color: var(--amber); }
.ic-violet { background: var(--violet-soft); color: var(--violet); }

/* ---------------------------------------------------------- auth pages -- */
.auth-body {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center;
  background:
    radial-gradient(1000px 460px at 85% -10%, rgba(124, 58, 237, .09), transparent 60%),
    radial-gradient(900px 420px at 10% -10%, rgba(79, 70, 229, .10), transparent 60%),
    var(--bg);
}
.auth-wrap { width: 100%; max-width: 440px; padding: 54px 22px 30px; }
.auth-brand { justify-content: center; display: flex; margin-bottom: 26px; }
.auth-card { padding: 32px 30px; box-shadow: var(--shadow-md); }
.auth-title { font-size: 1.45rem; margin-bottom: 4px; }
.auth-sub { color: var(--muted); font-size: .93rem; margin-bottom: 22px; }
.auth-alt { text-align: center; color: var(--muted); font-size: .9rem; margin: 20px 0 0; }
.auth-foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 18px 0; }

/* ------------------------------------------------------------- footer -- */
.footer { border-top: 1px solid var(--border); background: var(--surface); }
.footer-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding-top: 20px; padding-bottom: 20px;
  color: var(--muted); font-size: .85rem;
}
.footer-brand { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; color: var(--text); }

/* --------------------------------------------------------- responsive -- */
@media (max-width: 900px) {
  .course-hero { flex-direction: column; }
  .course-hero-thumb { width: 100%; }
}

@media (max-width: 760px) {
  .nav-toggle { display: inline-flex; }
  .nav-links {
    display: none;
    width: 100%; flex-direction: column; align-items: stretch; gap: 4px;
    padding: 10px 0 16px;
  }
  .nav-links.open { display: flex; }
  .nav-link { padding: 11px 14px; }
  .nav-user { justify-content: flex-start; }
  .nav-links .btn, .nav-links form { width: 100%; }
  .nav-inner { flex-wrap: wrap; }

  h1 { font-size: 1.45rem; }
  .hero { padding: 44px 0 20px; }
  .hero-stats { gap: 28px; }
  .main { padding-top: 20px; }
  .field-row { grid-template-columns: 1fr; }
  .field-small { max-width: none; }
  .form-card { padding: 22px 18px; }
  .course-hero { padding: 18px; }
  .table th, .table td { padding: 11px 12px; }
}

@media (max-width: 560px) {
  .card-grid, .session-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card { flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px; }
  .page-head .btn { width: 100%; }
  .table-card { overflow-x: auto; }
  .table { min-width: 560px; }
}

/* ==========================================================================
   v2 additions — member data & ledger system
   ========================================================================== */

/* Numbers & money in tables */
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.num, .table th.num { text-align: right; }
.table tfoot td { background: #fafbfe; border-top: 2px solid var(--border); }
.table-note { padding: 10px 18px 14px; margin: 0; }

/* Wide scrollable tables (ledger has 26 columns) */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-ledger { font-size: .84rem; min-width: 1500px; }
.table-ledger th, .table-ledger td { padding: 9px 10px; }
.ledger-group-row th[colspan="4"] { text-align: center; border-left: 1px solid var(--border); color: var(--primary); }
.table-report { min-width: 560px; }

/* Filter bars & tabs */
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-bar label { font-size: .86rem; font-weight: 600; color: var(--muted); }
.filter-bar select, .filter-bar input[type="search"], .filter-bar input[type="text"] {
  padding: 8px 12px; font-family: inherit; font-size: .9rem; color: var(--text);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: #fff;
}
.filter-bar select:focus, .filter-bar input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.filter-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 22px; box-shadow: var(--shadow-sm); }

.tabs { display: flex; gap: 6px; margin-bottom: 18px; border-bottom: 2px solid var(--border); flex-wrap: wrap; }
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 18px; margin-bottom: -2px; border-radius: 10px 10px 0 0;
  color: var(--muted); font-weight: 600; font-size: .93rem;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); background: var(--border-soft); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--primary-soft); }
.tab .ic { width: 16px; height: 16px; }

/* Progress bars */
.progress { width: 160px; max-width: 100%; height: 8px; border-radius: 99px; background: var(--border-soft); overflow: hidden; margin-top: 6px; }
.progress-bar { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), var(--primary-2)); transition: width .4s; }
.progress-sm { width: 90px; height: 6px; margin-top: 4px; }

/* ID card on profile page */
.id-card { padding: 20px 22px; margin-bottom: 20px; }
.id-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.id-info { flex: 1; min-width: 200px; }
.id-progress { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }

/* Profile grid */
.profile-card { max-width: 900px; }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 4px 18px; }
.pf-item { display: flex; flex-direction: column; gap: 2px; padding: 9px 0; border-bottom: 1px dashed var(--border-soft); }
.pf-item strong { font-size: .95rem; }
.memberno-form { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.memberno-input { width: 130px; padding: 5px 10px; font-family: inherit; font-size: .9rem; border: 1.5px solid var(--border); border-radius: 8px; }
.memberno-input:focus { outline: none; border-color: var(--primary); }

/* Ledger entry form */
.form-card-wide { max-width: 900px; }
.loan-title { display: flex; align-items: center; gap: 8px; margin: 26px 0 12px; font-size: 1.02rem; }
.loan-title .ic { color: var(--primary); }
.loan-fieldset { border: 1.5px solid var(--border); border-radius: 12px; padding: 14px 16px 4px; margin-bottom: 14px; }
.loan-fieldset legend { font-weight: 700; font-size: .9rem; padding: 0 8px; color: var(--primary); }
.loan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 14px; }

/* Inquiries */
.two-col { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 20px; align-items: start; }
.inquiry-card { padding: 16px 18px; margin-bottom: 14px; }
.inquiry-link { display: block; color: var(--text); transition: transform .12s, box-shadow .15s, border-color .15s; }
.inquiry-link:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.inquiry-active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.inquiry-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.inquiry-msg { margin: 10px 0 0; color: #3c425c; font-size: .93rem; }
.reply-box { margin-top: 14px; background: var(--green-soft); border: 1px solid #c4ecd9; border-radius: 12px; padding: 14px 16px; }
.reply-box strong { display: flex; align-items: center; gap: 6px; color: #047857; font-size: .88rem; margin-bottom: 6px; }
.reply-box p { margin: 0; font-size: .92rem; }
.inquiry-form-card h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }

.badge-status-open      { background: var(--amber-soft); color: var(--amber); }
.badge-status-inprogress{ background: var(--primary-soft); color: var(--primary); }
.badge-status-resolved  { background: var(--green-soft); color: #047857; }

@media (max-width: 960px) {
  .two-col { grid-template-columns: 1fr; }
  .id-progress { align-items: flex-start; }
}
@media (max-width: 560px) {
  .table-ledger { min-width: 1100px; }
}
