/* ══════════════════════════════════════════════════════════════
   AAZ Accounting System – Main Stylesheet
   ══════════════════════════════════════════════════════════════ */

:root {
  --primary:      #1E3A5F;
  --primary-light:#2E5F9E;
  --primary-pale: #D6E4F0;
  --accent:       #2E86AB;
  --success:      #27AE60;
  --warning:      #F39C12;
  --danger:       #E74C3C;
  --info:         #3498DB;

  --bg:           #F4F6F9;
  --surface:      #FFFFFF;
  --surface-alt:  #F8FAFC;
  --border:       #E0E6ED;
  --border-dark:  #CBD5E1;

  --text:         #1A2B3C;
  --text-muted:   #64748B;
  --text-light:   #94A3B8;

  --sidebar-w:    240px;
  --topbar-h:     64px;
  --radius:       10px;
  --shadow:       0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.05);
  --shadow-card:  0 2px 8px rgba(30,58,95,.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

/* ── Auth layout ─────────────────────────────────────────────── */
.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
}

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

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.5rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: -.01em;
}

.brand-icon {
  font-size: 1.5rem;
  opacity: .9;
}

.nav-menu {
  list-style: none;
  padding: 1rem 0;
  flex: 1;
}

.nav-item { position: relative; }

.nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1.25rem;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  transition: all .15s;
  font-size: .875rem;
  border-left: 3px solid transparent;
}

.nav-link:hover, .nav-item.active .nav-link {
  color: #fff;
  background: rgba(255,255,255,.1);
  border-left-color: #fff;
}

.nav-icon { font-size: 1rem; opacity: .8; }

.badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  padding: .15rem .45rem;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.1);
}

.user-info {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .75rem;
}

.user-avatar {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem;
  flex-shrink: 0;
}

.user-name { font-size: .85rem; font-weight: 600; }
.user-role { font-size: .75rem; opacity: .6; }

.btn-logout {
  width: 100%;
  padding: .5rem;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 6px;
  color: rgba(255,255,255,.8);
  cursor: pointer;
  font-size: .8rem;
  transition: background .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.2); }

/* ── Main content ─────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
}

.topbar-actions { display: flex; gap: .75rem; align-items: center; }

.content-body { padding: 2rem; flex: 1; }

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: .9rem;
  color: var(--primary);
}

.card-body { padding: 1.5rem; }

/* ── KPI Cards ────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--kpi-color, var(--accent));
}

.kpi-label { font-size: .78rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.6rem; font-weight: 700; color: var(--primary); margin: .35rem 0 .2rem; }
.kpi-sub { font-size: .78rem; color: var(--text-muted); }
.kpi-card.success { --kpi-color: var(--success); }
.kpi-card.warning { --kpi-color: var(--warning); }
.kpi-card.danger  { --kpi-color: var(--danger); }
.kpi-card.info    { --kpi-color: var(--info); }
.kpi-card.primary { --kpi-color: var(--primary); }

/* ── Charts grid ──────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.chart-container { position: relative; height: 280px; }

/* ── Tables ───────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

th {
  background: var(--bg);
  padding: .75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: .78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

td {
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

tr:hover td { background: var(--surface-alt); }

.tr-formation td { background: #F0FFF4; }
.tr-bank td { background: #FFF8F0; }
.tr-draft td { opacity: .75; }

/* ── Badges / tags ────────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  padding: .2rem .6rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
}

.tag-success { background: #DCFCE7; color: #166534; }
.tag-warning { background: #FEF9C3; color: #713F12; }
.tag-danger  { background: #FEE2E2; color: #991B1B; }
.tag-info    { background: #DBEAFE; color: #1E40AF; }
.tag-muted   { background: #F1F5F9; color: #475569; }
.tag-form    { background: #DCFCE7; color: #14532D; }

.confidence-high   { color: var(--success); }
.confidence-medium { color: var(--warning); }
.confidence-low    { color: var(--danger); }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem 1.25rem;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
}

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #219A52; }
.btn-outline   { background: transparent; border: 1px solid var(--border-dark); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-sm        { padding: .35rem .85rem; font-size: .78rem; }

/* ── Forms ────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .4rem; color: var(--text); }

input[type=text], input[type=email], input[type=password],
input[type=date], select, textarea {
  width: 100%;
  padding: .6rem .9rem;
  border: 1.5px solid var(--border-dark);
  border-radius: 8px;
  font-size: .9rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46,134,171,.12);
}

/* ── Upload zone ──────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border-dark);
  border-radius: var(--radius);
  padding: 3rem;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: var(--surface-alt);
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: #EBF5FB;
}

.upload-icon { font-size: 2.5rem; margin-bottom: 1rem; opacity: .5; }
.upload-text { font-size: .9rem; color: var(--text-muted); }
.upload-sub  { font-size: .78rem; color: var(--text-light); margin-top: .5rem; }

/* ── Alerts ───────────────────────────────────────────────────── */
.flash-container { margin-bottom: 1.5rem; }

.alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1.25rem;
  border-radius: 8px;
  margin-bottom: .5rem;
  font-size: .875rem;
  font-weight: 500;
}

.alert-success { background: #DCFCE7; color: #166534; border-left: 4px solid var(--success); }
.alert-danger  { background: #FEE2E2; color: #991B1B; border-left: 4px solid var(--danger); }
.alert-warning { background: #FEF9C3; color: #713F12; border-left: 4px solid var(--warning); }
.alert-info    { background: #DBEAFE; color: #1E40AF; border-left: 4px solid var(--info); }

.alert-close {
  background: none; border: none; font-size: 1.2rem;
  cursor: pointer; opacity: .6; padding: 0 .3rem;
}
.alert-close:hover { opacity: 1; }

/* ── Pagination ───────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: .25rem;
  align-items: center;
  justify-content: center;
  padding: 1rem 0;
}

.page-btn {
  padding: .4rem .75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  font-size: .83rem;
  transition: all .15s;
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  .charts-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ── Utility ──────────────────────────────────────────────────── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.font-mono   { font-family: "Courier New", monospace; font-size: .85em; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-100 { width: 100%; }
.hidden { display: none !important; }
