@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600&display=swap');

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

:root {
  --bg:       #F4F5F7;
  --bg2:      #FFFFFF;
  --bg3:      #EEEEF2;
  --border:   #E0E0E8;
  --text:     #1A1A2E;
  --text2:    #6B6B80;
  --primary:  #5046E4;
  --primary2: #3730A3;
  --green:    #1D9E75;
  --red:      #D85A30;
  --amber:    #C97B1A;
  --radius:   10px;
  --shadow:   0 1px 4px rgba(0,0,0,.08);
}

body { font-family: 'Vazirmatn', Tahoma, sans-serif; background: var(--bg); color: var(--text); direction: rtl; font-size: 14px; }

/* ── LAYOUT ── */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 210px; background: var(--bg2); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}

.logo {
  padding: 20px 16px 16px; border-bottom: 1px solid var(--border); text-align: center;
}
.logo-icon { font-size: 28px; margin-bottom: 6px; }
.logo h1 { font-size: 15px; font-weight: 600; color: var(--primary); }
.logo p { font-size: 11px; color: var(--text2); margin-top: 3px; }

nav { flex: 1; padding: 10px 0; overflow-y: auto; }

.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 18px; cursor: pointer; font-size: 13px;
  color: var(--text2); text-decoration: none;
  border-right: 3px solid transparent; transition: all .15s;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: #EEEEFF; color: var(--primary); border-right-color: var(--primary); font-weight: 500; }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  padding: 14px 22px; background: var(--bg2); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.topbar h2 { font-size: 16px; font-weight: 600; }

.content { flex: 1; overflow-y: auto; padding: 20px; }

/* ── SECTIONS ── */
.section { display: none; }
.section.active { display: block; }

/* ── CARDS ── */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-title { font-size: 13px; font-weight: 600; }

/* ── METRIC GRID ── */
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.metric-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.metric-card .label { font-size: 11px; color: var(--text2); margin-bottom: 6px; }
.metric-card .value { font-size: 22px; font-weight: 600; }
.metric-card .sub { font-size: 11px; color: var(--text2); margin-top: 3px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── ACCOUNTS GRID ── */
.accounts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.account-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; text-align: center; box-shadow: var(--shadow); }
.account-avatar { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; margin: 0 auto 10px; }
.account-name { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.account-type { font-size: 11px; color: var(--text2); margin-bottom: 10px; }
.account-balance { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.account-currency { font-size: 11px; color: var(--text2); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg2); color: var(--text); cursor: pointer;
  font-size: 12px; font-family: inherit; transition: all .15s; text-decoration: none;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary2); border-color: var(--primary2); }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-danger { border-color: #f5c2c7; color: var(--red); }
.btn-danger:hover { background: #FFF0EE; }
.btn-green { border-color: #b7e5d4; color: var(--green); }
.btn-green:hover { background: #EDFAF4; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: right; padding: 9px 12px; border-bottom: 1px solid var(--border); color: var(--text2); font-weight: 500; font-size: 12px; white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ── BADGES ── */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 500; }
.badge-green { background: #E6F9F1; color: #0F7950; }
.badge-amber { background: #FFF4E0; color: #995A00; }
.badge-red   { background: #FFEEEB; color: #B03020; }
.badge-blue  { background: #EEF2FF; color: #3730A3; }
.badge-gray  { background: var(--bg3); color: var(--text2); }

/* ── PROGRESS ── */
.progress { background: var(--bg3); border-radius: 20px; height: 7px; overflow: hidden; margin: 6px 0; }
.progress-bar { height: 100%; border-radius: 20px; background: var(--primary); transition: width .4s; }

/* ── FORM ── */
.form-group { margin-bottom: 13px; }
.form-group label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 5px; font-weight: 500; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg2); color: var(--text);
  font-family: inherit; font-size: 13px; direction: rtl;
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── MODAL ── */
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 200; align-items: center; justify-content: center; }
.modal-bg.open { display: flex; }
.modal { background: var(--bg2); border-radius: 14px; padding: 22px; width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,.15); }
.modal h3 { font-size: 15px; font-weight: 600; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* ── FILTER BAR ── */
.filter-bar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-bar input,
.filter-bar select { padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg2); color: var(--text); font-family: inherit; font-size: 12px; }
.filter-bar input { flex: 1; min-width: 140px; }

/* ── TABS ── */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.tab { padding: 8px 18px; font-size: 13px; cursor: pointer; color: var(--text2); background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; font-family: inherit; transition: all .15s; }
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── EMPTY STATE ── */
.empty { text-align: center; padding: 48px; color: var(--text2); font-size: 13px; }
.empty span { display: block; font-size: 36px; margin-bottom: 10px; }

/* ── RECEIPT BOX ── */
.receipt-box { background: var(--bg); border: 1px dashed var(--border); border-radius: 8px; padding: 14px; font-size: 12px; }
.receipt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.receipt-grid .rk { font-size: 11px; color: var(--text2); margin-bottom: 2px; }
.receipt-grid .rv { font-size: 13px; font-weight: 500; }

/* ── TOAST ── */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1A1A2E; color: #fff; padding: 10px 22px; border-radius: 8px;
  font-size: 13px; opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 999;
}
#toast.show { opacity: 1; }

/* ── WORKER CARD ── */
.worker-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.worker-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.worker-avatar { width: 42px; height: 42px; border-radius: 50%; background: #EEEEFF; color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 16px; flex-shrink: 0; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar .logo h1, .sidebar .logo p, .nav-item span { display: none; }
  .two-col { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

/* ── V2 ADDITIONS ── */
.alert-banner {
  background: #FFF8E0; border: 1px solid #F5C842; border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 16px; font-size: 13px; color: #7A5800;
}
.group-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; margin: 16px 0 10px;
  background: var(--bg3); border-radius: 8px; font-size: 13px; font-weight: 600;
}
.group-header:first-child { margin-top: 0; }
.loan-group-block .card { margin-bottom: 10px; }
.modal { max-width: 520px; }
