/* ── Reset & Base ──────────────────────────────────────────────────── */
:root {
  --sidebar-bg: #233670;
  --sidebar-hover: #233670;
  --sidebar-w: 64px;
  --primary: #233670;
  --primary-dark: #233670;
  --primary-light: #eef1fa;
  --danger: #c0392b;
  --success: #27ae60;
  --warning: #e67e22;
  --text: #233670;
  --muted: #7f8c8d;
  --border: #dde3e8;
  --bg: #f0f3f6;
  --white: #ffffff;
  --header-h: 56px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08);
  --shadow: 0 2px 8px rgba(0, 0, 0, .10);
  --radius: 6px;
}

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

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

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

/* ── Sidebar ───────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  box-shadow: 2px 0 8px rgba(0, 0, 0, .15);
}

.sidebar .logo {
  width: 100%;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .15);
  flex-shrink: 0;
}

.sidebar .logo svg {
  width: 28px;
  height: 28px;
  fill: #fff;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 0;
  width: 100%;
  flex: 1;
}

.sidebar nav a {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: rgba(255, 255, 255, .65);
  text-decoration: none;
  transition: all .2s;
  position: relative;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  background: rgba(255, 255, 255, .15);
  color: #fff;
}

.sidebar nav a svg {
  width: 20px;
  height: 20px;
}

.sidebar nav a .tooltip {
  position: absolute;
  left: calc(var(--sidebar-w) + 4px);
  background: #1a1a2e;
  color: #fff;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 300;
}

.sidebar nav a:hover .tooltip {
  opacity: 1;
}

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

/* ── Top bar ───────────────────────────────────────────────────────── */
.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar .menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  padding: 4px;
}

.topbar .search-box {
  flex: 1;
  max-width: 440px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  background: #f8fafb;
}

.topbar .search-box svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
  flex-shrink: 0;
}

.topbar .search-box input {
  border: none;
  background: none;
  outline: none;
  font-size: 13px;
  color: var(--text);
  width: 100%;
}

.topbar .spacer {
  flex: 1;
}

.topbar .user-section {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.topbar .user-section a {
  color: var(--muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar .user-section a:hover {
  color: var(--primary);
}

.topbar .user-name {
  font-weight: 600;
  color: var(--text);
}

.topbar .badge-notif {
  background: #e74c3c;
  color: #fff;
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: bold;
}

/* ── Breadcrumb ────────────────────────────────────────────────────── */
.breadcrumb-bar {
  padding: 10px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb-bar a {
  color: var(--muted);
  text-decoration: none;
}

.breadcrumb-bar a:hover {
  color: var(--primary);
}

.breadcrumb-bar .sep {
  opacity: .5;
}

.breadcrumb-bar .current {
  color: var(--primary);
  font-weight: 600;
}

/* ── Page content ──────────────────────────────────────────────────── */
.page-content {
  padding: 24px;
  flex: 1;
}

/* ── Panel / Card ──────────────────────────────────────────────────── */
.panel {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  overflow: hidden;
}

.panel-header {
  background: #f4f7f9;
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-body {
  padding: 20px;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 20px;
}

.card h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ── Form ──────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 140px;
}

.form-group.full {
  grid-column: 1 / -1;
  flex: 0 0 100%;
}

.form-group.w2 {
  flex: 0 0 calc(50% - 8px);
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

input[type=text],
input[type=email],
input[type=password],
input[type=number],
input[type=date],
input[type=month],
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  transition: border-color .2s, box-shadow .2s;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237f8c8d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(42, 143, 165, .12);
}

textarea {
  resize: vertical;
  min-height: 72px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-check input[type=checkbox] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.form-check label {
  font-size: 13px;
  font-weight: normal;
  color: var(--text);
}

/* ── Filters panel ─────────────────────────────────────────────────── */
.filters-panel {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.filters-panel .fp-header {
  background: #f4f7f9;
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.filters-panel .fp-header span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.filters-panel .fp-body {
  padding: 20px;
}

.filters-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filters-row .form-group {
  flex: 1;
  min-width: 160px;
  max-width: 280px;
}

.toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  font-weight: 300;
}

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  text-decoration: none;
  transition: all .2s;
  letter-spacing: .3px;
}

.btn svg {
  width: 15px;
  height: 15px;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-outline {
  background: var(--white);
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary-light);
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
}

.btn-danger:hover {
  background: #a93226;
}

.btn-success {
  background: var(--success);
  color: var(--white);
}

.btn-muted {
  background: #ecf0f1;
  color: var(--muted);
}

.btn-muted:hover {
  background: #dde3e8;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 11px;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
  align-items: center;
}

/* ── Table ─────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: #f4f7f9;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

tbody td {
  border-bottom: 1px solid #edf1f4;
  padding: 10px 14px;
  color: var(--text);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: #f8fbfc;
}

tfoot td {
  background: #f4f7f9;
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  font-weight: 700;
  font-size: 13px;
}

td.num,
tfoot td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

td.diff-ok {
  text-align: right;
  color: var(--success);
  font-weight: 700;
}

td.diff-bad {
  text-align: right;
  color: var(--danger);
  font-weight: 700;
}

.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 32px;
  font-size: 13px;
}

/* ── Alerts ────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-success {
  background: #e8f8ee;
  border: 1px solid #b8e6c8;
  color: #1e6e3a;
}

.alert-error {
  background: #fdf0ef;
  border: 1px solid #f0b8b4;
  color: #7a1c14;
}

.alert-info {
  background: #e8f4f8;
  border: 1px solid #b0d8e8;
  color: #0c5460;
}

.alert-warning {
  background: #fef9e7;
  border: 1px solid #f0dc88;
  color: #7a5800;
}

/* ── Badge ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2px;
}

.badge-ok {
  background: #e2f5ea;
  color: #1e6e3a;
}

.badge-danger {
  background: #fde8e6;
  color: #8b2118;
}

.badge-warning {
  background: #fef4e0;
  color: #7a5800;
}

.badge-info {
  background: #dff0f8;
  color: #0d5f7a;
}

.badge-muted {
  background: #ecf0f1;
  color: var(--muted);
}

/* ── Summary cards ─────────────────────────────────────────────────── */
.summary-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.summary-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  border-left: 3px solid var(--primary);
}

.summary-card.danger {
  border-left-color: var(--danger);
}

.summary-card.success {
  border-left-color: var(--success);
}

.summary-card.warning {
  border-left-color: var(--warning);
}

.summary-card label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  display: block;
}

.summary-card .val {
  font-size: 24px;
  font-weight: 700;
  margin-top: 6px;
  color: var(--text);
}

.summary-card .val.sm {
  font-size: 17px;
}

/* ── Calc section ──────────────────────────────────────────────────── */
.calc-section {
  background: #f0f9fb;
  border: 1px solid #b8dde8;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 20px;
}

.calc-section h3 {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-dark);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 14px;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.calc-item label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}

.calc-value {
  font-size: 22px;
  font-weight: 700;
  padding: 4px 0;
}

.calc-value.zero {
  color: var(--success);
}

.calc-value.pos {
  color: var(--danger);
}

.calc-value.neg {
  color: var(--warning);
}

.calc-detail {
  font-size: 11px;
  color: var(--muted);
}

/* ── Login ─────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  background: var(--bg);
}

.login-sidebar {
  width: 420px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--white);
}

.login-sidebar .brand-icon {
  width: 64px;
  height: 64px;
  background: rgba(255, 255, 255, .15);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.login-sidebar h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.login-sidebar p {
  font-size: 14px;
  opacity: .75;
  text-align: center;
  line-height: 1.6;
}

.login-form-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.login-box {
  width: 100%;
  max-width: 380px;
}

.login-box h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.login-box .sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 28px;
}

.login-box .form-group {
  margin-bottom: 16px;
}

.login-box .form-group label {
  font-size: 13px;
}

/* ── Breadcrumb inline ─────────────────────────────────────────────── */
.breadcrumb {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
}

.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb .sep {
  margin: 0 5px;
  opacity: .5;
}

/* ── Flash in topbar ───────────────────────────────────────────────── */
.flash-bar {
  padding: 0 24px 0 24px;
  padding-top: 14px;
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .main-wrap {
    margin-left: 0;
  }

  .login-sidebar {
    display: none;
  }

  .filters-row .form-group {
    max-width: 100%;
  }
}