:root {
  --primary: #2e7d32;
  --primary-hover: #1b5e20;
  --primary-light: #e8f5e9;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --text: #2c3e50;
  --muted: #6b7280;
  --border: #e5ebe7;
  --sidebar-w: 240px;
  --topbar-h: 60px;
}

body {
  font-family: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: #4a5568;
  font-size: 0.925rem;
}

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

/* ---------- Bootstrap theme overrides ---------- */
.btn-primary, .btn-success {
  --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary);
  --bs-btn-hover-bg: var(--primary-hover); --bs-btn-hover-border-color: var(--primary-hover);
  --bs-btn-active-bg: var(--primary-hover); --bs-btn-active-border-color: var(--primary-hover);
  --bs-btn-disabled-bg: var(--primary); --bs-btn-disabled-border-color: var(--primary);
}
.btn-outline-primary {
  --bs-btn-color: var(--primary); --bs-btn-border-color: var(--primary);
  --bs-btn-hover-bg: var(--primary); --bs-btn-hover-border-color: var(--primary);
  --bs-btn-active-bg: var(--primary-hover);
}
.form-control:focus, .form-select:focus {
  border-color: #81c784; box-shadow: 0 0 0 .2rem rgba(46,125,50,.15);
}
.form-label { font-weight: 500; color: var(--text); margin-bottom: .3rem; }
.nav-pills .nav-link.active { background: var(--primary); }
.nav-pills .nav-link { color: var(--text); }
.page-link { color: var(--primary); }
.active > .page-link, .page-link.active { background: var(--primary); border-color: var(--primary); }

/* ---------- Topbar ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 1030;
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 1rem;
}
.topbar .brand { display: flex; align-items: center; gap: .6rem; color: var(--primary); font-weight: 700; text-decoration: none; }
.topbar .brand img { height: 38px; object-fit: contain; }
.topbar .icon-btn {
  border: 0; background: transparent; font-size: 1.3rem; color: var(--text);
  width: 40px; height: 40px; border-radius: 10px; position: relative;
}
.topbar .icon-btn:hover { background: var(--primary-light); color: var(--primary); }
.topbar .badge-dot {
  position: absolute; top: 4px; right: 2px; font-size: .65rem; min-width: 18px;
  border-radius: 9px; background: #e53935; color: #fff; padding: 1px 5px;
}
.user-chip { display: flex; align-items: center; gap: .5rem; cursor: pointer; padding: .3rem .6rem; border-radius: 10px; }
.user-chip:hover { background: var(--primary-light); }
.user-chip .avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: .85rem;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w); z-index: 1020;
  background: linear-gradient(180deg, #ffffff, #f3f7f4); border-right: 1px solid var(--border);
  padding: 1rem .75rem; overflow-y: auto; transition: transform .2s ease;
}
.sidebar .section { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1rem .75rem .4rem; }
.sidebar .nav-link {
  display: flex; align-items: center; gap: .75rem; color: var(--text); padding: .6rem .8rem;
  border-radius: 10px; margin-bottom: 2px; font-weight: 500;
}
.sidebar .nav-link i { font-size: 1.1rem; width: 22px; text-align: center; }
.sidebar .nav-link:hover { background: var(--primary-light); color: var(--primary); }
.sidebar .nav-link.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(46,125,50,.25); }
.sidebar .nav-link .count { margin-left: auto; font-size: .7rem; }

.main { margin-left: var(--sidebar-w); padding: calc(var(--topbar-h) + 1.5rem) 1.5rem 2rem; min-height: 100vh; }

body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .main { margin-left: 0; }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  body.sidebar-open .sidebar { transform: none; box-shadow: 0 10px 30px rgba(0,0,0,.15); }
  .main { margin-left: 0; padding: calc(var(--topbar-h) + 1rem) 1rem 2rem; }
  .topbar .brand span { display: none; }
}

/* ---------- Cards & tables ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.35rem; font-weight: 700; color: var(--text); margin: 0; }
.card { border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: var(--surface); border-bottom: 1px solid var(--border); font-weight: 600; color: var(--text); border-radius: 14px 14px 0 0 !important; }
.card.stat { padding: 1rem 1.15rem; display: flex; flex-direction: row; align-items: center; gap: 1rem; height: 100%; }
.stat .ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem; flex-shrink: 0; }
.stat .label { color: var(--muted); font-size: .8rem; }
.stat .value { font-size: 1.35rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.ico-green { background: var(--primary-light); color: var(--primary); }
.ico-amber { background: #fff7e6; color: #d97706; }
.ico-blue { background: #e8f1fd; color: #1d4ed8; }
.ico-red { background: #fdecec; color: #dc2626; }
.ico-gray { background: #f1f3f5; color: #475569; }

.table { --bs-table-hover-bg: #f6faf7; margin-bottom: 0; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafcfb; border-bottom-width: 1px; white-space: nowrap; }
.table td { vertical-align: middle; }
.table .money { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.text-money { font-variant-numeric: tabular-nums; }
.amount-in { color: var(--primary); font-weight: 600; }
.amount-out { color: #dc2626; font-weight: 600; }
.row-link { cursor: pointer; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }
.empty i { font-size: 2rem; display: block; margin-bottom: .5rem; opacity: .6; }

.badge { font-weight: 500; padding: .38em .7em; border-radius: 8px; }
.badge.bg-warning { color: #7a4b00 !important; background: #fff1cc !important; }
.badge.bg-success { background: #dcf2df !important; color: #1b5e20 !important; }
.badge.bg-danger { background: #fde2e2 !important; color: #b91c1c !important; }
.badge.bg-secondary { background: #eceff1 !important; color: #455a64 !important; }
.badge.bg-dark { background: #e5e7eb !important; color: #374151 !important; }
.badge.bg-light { background: #f8fafc !important; color: #64748b !important; border: 1px solid var(--border); }

/* ---------- Request detail ---------- */
.kv { display: grid; grid-template-columns: 170px 1fr; gap: .45rem 1rem; }
.kv dt { color: var(--muted); font-weight: 400; }
.kv dd { margin: 0; color: var(--text); font-weight: 500; word-break: break-word; }
@media (max-width: 575.98px) { .kv { grid-template-columns: 1fr; } .kv dd { margin-bottom: .4rem; } }

.steps { list-style: none; padding: 0; margin: 0; position: relative; }
.steps li { position: relative; padding: 0 0 1.25rem 2.5rem; }
.steps li::before { content: ""; position: absolute; left: 14px; top: 30px; bottom: 0; width: 2px; background: var(--border); }
.steps li:last-child::before { display: none; }
.steps .dot { position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: .9rem; background: #eceff1; color: #546e7a; }
.steps .dot.ok { background: var(--primary); color: #fff; }
.steps .dot.now { background: #f59e0b; color: #fff; box-shadow: 0 0 0 4px #fff3d6; }
.steps .dot.bad { background: #dc2626; color: #fff; }
.steps .who { font-weight: 600; color: var(--text); }
.steps .meta { font-size: .8rem; color: var(--muted); }
.steps .comment { background: #f8faf9; border-left: 3px solid var(--primary); padding: .4rem .6rem; border-radius: 6px; margin-top: .35rem; font-size: .85rem; }

.total-box { background: var(--primary-light); border-radius: 12px; padding: .75rem 1rem; color: var(--primary-hover); }
.total-box .value { font-size: 1.4rem; font-weight: 700; }

/* ---------- Items editor ---------- */
.items-table input { min-width: 90px; }
.items-table td { padding: .35rem; }
.items-table .col-content { min-width: 220px; }
.items-table .line-total { white-space: nowrap; font-weight: 600; text-align: right; color: var(--text); }

/* ---------- Notifications dropdown ---------- */
.noti-menu { width: 360px; max-width: calc(100vw - 2rem); padding: 0; overflow: hidden; border-radius: 14px; }
.noti-menu .head { padding: .75rem 1rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.noti-menu .list { max-height: 420px; overflow-y: auto; }
.noti-item { display: flex; gap: .7rem; width: 100%; text-align: left; border: 0; background: transparent; padding: .7rem 1rem; border-bottom: 1px solid #f2f4f3; color: inherit; }
.noti-item:hover { background: #f6faf7; }
.noti-item.unread { background: #f1f8f2; }
.noti-item .ni { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.noti-item .nt { font-size: .85rem; color: var(--text); line-height: 1.35; }
.noti-item .tm { font-size: .72rem; color: var(--muted); margin-top: 2px; }

/* ---------- Auth pages ---------- */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background: linear-gradient(rgba(255,255,255,.88), rgba(255,255,255,.88)), url("../images/login-bg.jpg") center/cover no-repeat;
}
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 18px; padding: 2rem; box-shadow: 0 20px 50px rgba(20, 60, 30, .15); }
.auth-card .logo { max-height: 60px; object-fit: contain; display: block; margin: 0 auto 1rem; }
.auth-card h1 { font-size: 1.3rem; text-align: center; color: var(--text); font-weight: 700; margin-bottom: .25rem; }
.auth-card .sub { text-align: center; color: var(--muted); margin-bottom: 1.5rem; }

.flow-table select { min-width: 180px; }

@media (max-width: 575.98px) {
  .card.stat { flex-direction: column; align-items: flex-start; gap: .5rem; padding: .85rem; }
  .stat .ico { width: 38px; height: 38px; font-size: 1.1rem; }
  .stat .value { font-size: 1.15rem; }
  .page-head h1 { font-size: 1.2rem; }
}
.help { font-size: .8rem; color: var(--muted); }
