/* IGS Accounting Suite - base layout and components */
:root {
  --bg: #f3f5fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: #e3e8f2;
  --primary: #4338ca;
  --primary-dark: #342d9e;
  --accent: #0ea5a4;
  --green: #047857;
  --red: #b91c1c;
  --amber: #b45309;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(15, 23, 42, .06);
  --sidebar: #101a2f;
  --sidebar-soft: #17233d;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Ubuntu, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; }
code, .mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 700; }
.list { margin: 8px 0 0 18px; padding: 0; }
.list li { margin-bottom: 4px; }

/* layout -------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-content { padding: 18px 22px 40px; flex: 1; }
.app-footer {
  padding: 12px 22px 22px; color: var(--muted); font-size: 12px;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
}
.sidebar {
  width: 254px; background: var(--sidebar); color: #cfd8ea; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; flex-shrink: 0;
}
.sidebar-brand { display: flex; gap: 10px; align-items: center; padding: 16px 16px 12px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #0ea5a4); color: #fff; font-weight: 700; font-size: 13px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { color: #fff; font-size: 13.5px; }
.brand-text small { color: #94a3b8; font-size: 11px; }
.sidebar-nav { padding: 6px 10px 20px; display: flex; flex-direction: column; gap: 2px; }
.nav-section {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #7c8aa5;
  padding: 14px 8px 6px;
}
.nav-item {
  color: #d3dcee; padding: 8px 10px; border-radius: var(--radius-sm); font-size: 13.5px;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--sidebar-soft); text-decoration: none; color: #fff; }
.nav-item.active { background: var(--sidebar-soft); border-left-color: #38bdf8; color: #fff; font-weight: 600; }
.sidebar-foot {
  margin-top: auto; padding: 12px 16px; border-top: 1px solid #1e293b; color: #7c8aa5;
  font-size: 11.5px; display: flex; justify-content: space-between;
}

/* navbar ------------------------------------------------------------- */
.navbar {
  background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 18px;
  display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 20;
}
.nav-toggle { display: none; }
.global-search { display: flex; gap: 8px; flex: 1; max-width: 620px; }
.global-search .input { flex: 1; }
.navbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.fy-chip {
  background: #eef2ff; color: var(--primary-dark); border-radius: 999px; padding: 5px 12px;
  font-size: 12px; font-weight: 600;
}
.user-box { display: flex; align-items: center; gap: 9px; position: relative; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: #e0e7ff; color: var(--primary-dark);
  display: grid; place-items: center; font-weight: 700;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta small { color: var(--muted); font-size: 11px; }
.dropdown { position: relative; }
.dropdown-toggle { background: none; border: 0; font-size: 15px; cursor: pointer; color: var(--muted); }
.dropdown-menu {
  display: none; position: absolute; right: 0; top: 28px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); min-width: 170px; padding: 6px; z-index: 40;
}
.dropdown-menu a, .dropdown-link {
  display: block; padding: 8px 10px; border-radius: 7px; color: var(--ink-soft); font-size: 13px;
  background: none; border: 0; width: 100%; text-align: left; cursor: pointer;
}
.dropdown-menu a:hover, .dropdown-link:hover { background: var(--panel-soft); text-decoration: none; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-form { margin: 0; }

/* page head ---------------------------------------------------------- */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-title { font-size: 21px; }
.page-sub { color: var(--muted); margin: 2px 0 0; font-size: 13px; }
.page-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* cards -------------------------------------------------------------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden;
}
.card-head {
  padding: 13px 16px; border-bottom: 1px solid var(--line); display: flex; gap: 12px;
  align-items: center; flex-wrap: wrap; background: linear-gradient(180deg, #fff, #fbfcff);
}
.card-title { font-size: 15px; }
.card-sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.card-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-body { padding: 16px; }
.card-foot {
  padding: 13px 16px; border-top: 1px solid var(--line); background: var(--panel-soft);
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.split-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.split-grid > .card { margin: 0 0 16px; }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }

/* stat cards --------------------------------------------------------- */
.stat-card {
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm); padding: 13px 14px; display: flex; flex-direction: column; gap: 3px;
  box-shadow: var(--shadow); color: inherit;
}
.stat-card:hover { text-decoration: none; transform: translateY(-1px); }
.stat-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.stat-value { font-size: 19px; font-weight: 700; }
.stat-sub { font-size: 11.5px; color: var(--muted); }
.accent-blue { border-left-color: #2563eb; }
.accent-indigo { border-left-color: #4f46e5; }
.accent-green { border-left-color: #059669; }
.accent-amber { border-left-color: #d97706; }
.accent-teal { border-left-color: #0d9488; }
.accent-cyan { border-left-color: #0891b2; }
.accent-red { border-left-color: #dc2626; }
.accent-orange { border-left-color: #ea580c; }
.accent-purple { border-left-color: #7c3aed; }
.accent-yellow { border-left-color: #ca8a04; }

/* buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; cursor: pointer; background: #eef1f8; color: var(--ink-soft);
  white-space: nowrap;
}
.btn:hover { filter: brightness(.97); text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-light { background: #fff; border-color: var(--line); color: var(--ink-soft); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.icon-btn { background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--ink-soft); }

/* tables ------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
.data-table thead th {
  background: var(--panel-soft); text-align: left; padding: 9px 10px; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .04em; color: #475569; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table td { padding: 9px 10px; border-bottom: 1px solid #eef1f8; vertical-align: top; }
.data-table tbody tr:hover { background: #fbfcff; }
.data-table .ta-right { text-align: right; }
.data-table .ta-center { text-align: center; }
.data-table .empty { text-align: center; color: var(--muted); padding: 22px; }
.total-row td, .total-row { background: #f1f5fd; font-weight: 700; }
.opening-row td { background: #f8fafc; color: var(--ink-soft); font-weight: 600; }
.group-head th { background: #eef2ff; color: var(--primary-dark); font-size: 12px; }
.sub-total td, .sub-total th { background: #f8fafc; font-weight: 700; }
.ta-right.in, .in { color: var(--green); }
.ta-right.out, .out { color: var(--red); }
.ta-right.due, .due { color: var(--red); font-weight: 700; }
.line-table input { width: 100%; }
.line-table td { padding: 5px 6px; }
.summary-table { width: 100%; border-collapse: collapse; }
.summary-table th { text-align: left; padding: 7px 10px; font-weight: 600; color: var(--ink-soft); border-bottom: 1px solid #eef1f8; }
.summary-table td { padding: 7px 10px; border-bottom: 1px solid #eef1f8; }
.summary-table.wide th { width: 62%; }
.summary-table tr.grand th, .summary-table tr.grand td { background: #eef2ff; font-size: 15px; font-weight: 700; }
.pl-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.totals-grid { display: grid; grid-template-columns: minmax(0, 320px) 1fr; gap: 16px; align-items: start; margin-top: 14px; }
.amount-words { background: var(--panel-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }

/* badges and pills ---------------------------------------------------- */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #e0e7ff; color: #3730a3; }
.badge-muted { background: #eef1f8; color: #475569; }

/* forms -------------------------------------------------------------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; }
.col-1 { grid-column: span 1; } .col-2 { grid-column: span 2; } .col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; } .col-5 { grid-column: span 5; } .col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; } .col-8 { grid-column: span 8; } .col-9 { grid-column: span 9; }
.col-12 { grid-column: span 12; }
.filter-actions { display: flex; align-items: flex-end; gap: 8px; }
.sub-head { font-size: 13px; color: var(--primary-dark); margin: 4px 0 6px; }
.inline-form { display: inline; }
.inline-edit { display: flex; gap: 6px; align-items: center; }
.inline-add { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.inline-form button { vertical-align: middle; }

/* tabs ---------------------------------------------------------------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab {
  padding: 7px 13px; border-radius: 999px; background: #fff; border: 1px solid var(--line);
  color: var(--ink-soft); font-size: 13px; font-weight: 600;
}
.tab:hover { text-decoration: none; border-color: #c7d2fe; }
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* alerts, toasts ------------------------------------------------------ */
.alert { border-radius: var(--radius-sm); padding: 10px 13px; font-size: 13px; border: 1px solid; margin: 10px 0; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-danger { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.toast-stack { position: fixed; top: 70px; right: 20px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast-stack.static { position: static; }
.toast {
  background: #fff; border: 1px solid var(--line); border-left: 4px solid #64748b; padding: 11px 13px;
  border-radius: var(--radius-sm); box-shadow: var(--shadow); display: flex; gap: 10px; align-items: center;
  min-width: 260px; max-width: 380px; font-size: 13px;
}
.toast-success { border-left-color: var(--green); }
.toast-error { border-left-color: var(--red); }
.toast-warning { border-left-color: var(--amber); }
.toast-info { border-left-color: #2563eb; }
.toast-close { margin-left: auto; background: none; border: 0; font-size: 16px; cursor: pointer; color: var(--muted); }

/* pagination ---------------------------------------------------------- */
.pager { display: flex; gap: 6px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.pg { padding: 5px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; font-size: 12.5px; }
.pg.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.pg-gap { color: var(--muted); }
.pg-info { margin-left: auto; color: var(--muted); font-size: 12px; }

/* quick actions, reports ---------------------------------------------- */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.quick-btn {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--panel-soft);
}
.quick-btn:hover { text-decoration: none; border-color: #c7d2fe; background: #fff; }
.quick-btn strong { display: block; }
.quick-btn span { color: var(--muted); font-size: 12px; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.report-tile {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; background: #fff;
}
.report-tile:hover { text-decoration: none; border-color: #c7d2fe; box-shadow: var(--shadow); }
.report-tile strong { display: block; }
.report-tile span { color: var(--muted); font-size: 12px; }
.report-actions { display: flex; gap: 8px; }
.permission-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.permission-item {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; display: flex;
  gap: 10px; align-items: flex-start; background: #fff;
}
.permission-item small { display: block; color: var(--muted); font-size: 11.5px; }
.steps { margin: 10px 0 0 18px; }
.steps li { margin-bottom: 6px; }
.steps .active { font-weight: 700; color: var(--primary-dark); }
.steps .done { color: var(--green); }
.doc-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 12px; }
.doc-summary .label { display: block; color: var(--muted); font-size: 11.5px; text-transform: uppercase; }
.doc-summary .value { font-weight: 650; }
.readout {
  border: 1px dashed var(--line); background: var(--panel-soft); border-radius: var(--radius-sm);
  padding: 8px 10px; font-weight: 650; color: var(--primary-dark);
}
.thumb { max-width: 120px; max-height: 80px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: #fff; }
.check-field { display: flex; flex-direction: column; justify-content: flex-end; }
.check-label { display: flex; gap: 7px; align-items: center; font-size: 13px; color: var(--ink-soft); }
.item-search { min-width: 260px; }
.error-card { max-width: 560px; margin: 8% auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); }
.auth-error-body { background: var(--bg); }

/* charts -------------------------------------------------------------- */
.chart { width: 100%; height: 240px; }
.chart svg { width: 100%; height: 100%; }
.chart-legend { display: flex; gap: 14px; justify-content: center; margin-top: 6px; font-size: 12px; color: var(--muted); }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

/* login --------------------------------------------------------------- */
.auth-body { background: linear-gradient(135deg, #0f172a, #1e293b 55%, #312e81); min-height: 100vh; }
.auth-shell {
  display: grid; grid-template-columns: 1.05fr .95fr; max-width: 1080px; margin: 4vh auto; background: #fff;
  border-radius: 20px; overflow: hidden; box-shadow: 0 30px 60px rgba(2, 6, 23, .35);
}
.auth-brand { background: linear-gradient(160deg, #111c33, #1e3a8a 60%, #0f766e); color: #e2e8f5; padding: 38px 34px; }
.auth-brand h1 { font-size: 25px; margin: 14px 0 6px; color: #fff; }
.auth-sub { color: #b9c6e2; font-size: 13px; }
.auth-points { margin: 20px 0 0 18px; padding: 0; font-size: 13px; color: #d7e0f3; }
.auth-points li { margin-bottom: 8px; }
.auth-foot { margin-top: 26px; display: flex; justify-content: space-between; font-size: 12px; color: #9fb0d0; }
.auth-logo { max-width: 150px; background: #fff; border-radius: 10px; padding: 6px; }
.auth-form-panel { padding: 38px 34px; }
.auth-form-panel h2 { font-size: 20px; }
.auth-form { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.auth-hint { margin-top: 18px; background: var(--panel-soft); border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 12px; font-size: 12.5px; }
.auth-hint code { background: #eef2ff; padding: 1px 5px; border-radius: 5px; }
.install-wrap { max-width: 980px; margin: 30px auto; padding: 0 16px 40px; }
.install-head { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); margin-bottom: 16px; }
.install-head h1 { font-size: 22px; }
.install-head p { color: var(--muted); }

/* print toolbar (screen) --------------------------------------------- */
.print-body { background: #f1f5f9; }
.print-toolbar { display: flex; gap: 10px; align-items: center; padding: 12px 18px; background: #fff; border-bottom: 1px solid #e2e8f0; flex-wrap: wrap; }

/* responsive ---------------------------------------------------------- */
@media (max-width: 1100px) {
  .stat-grid, .stat-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid, .split-grid, .pl-grid { grid-template-columns: minmax(0, 1fr); }
  .totals-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: -270px; top: 0; z-index: 60; transition: left .2s ease; height: 100%;
  }
  body.sidebar-open .sidebar { left: 0; }
  .nav-toggle { display: inline-flex; }
  .auth-shell { grid-template-columns: minmax(0, 1fr); margin: 0; border-radius: 0; min-height: 100vh; }
  .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9 { grid-column: span 6; }
  .col-1 { grid-column: span 4; }
}
@media (max-width: 620px) {
  .app-content { padding: 14px 12px 30px; }
  .stat-grid, .stat-grid.compact { grid-template-columns: minmax(0, 1fr); }
  .col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-12 { grid-column: span 12; }
  .global-search { max-width: none; }
  .fy-chip { display: none; }
  .user-meta { display: none; }
  .toast-stack { left: 12px; right: 12px; top: 62px; }
}
