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

:root {
  --ink: #12213D;
  --ink-soft: #4B5A78;
  --ink-faint: #8994A8;
  --parchment: #F7F5EF;
  --surface: #FFFFFF;
  --border: #E4E0D4;
  --border-strong: #D3CDB8;
  --gold: #B9862E;
  --gold-soft: #F3E7CE;
  --navy-deep: #0B1830;
  --navy-mid: #16294A;

  --status-green: #2F9E44;
  --status-green-bg: #E7F6EA;
  --status-red: #E03131;
  --status-red-bg: #FDEBEB;
  --status-blue: #1971C2;
  --status-blue-bg: #E8F1FC;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 1px 2px rgba(18, 33, 61, 0.06), 0 4px 12px rgba(18, 33, 61, 0.05);
  --font: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--font);
  direction: rtl;
}

body { min-height: 100vh; }

button, input, select {
  font-family: var(--font);
}

.hidden { display: none !important; }

/* ---------- App shell ---------- */

.topbar {
  background: var(--navy-deep);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar img.logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gold-soft);
  object-fit: cover;
}

.topbar .titles h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.topbar .titles p {
  margin: 2px 0 0;
  font-size: 12px;
  color: #C7CEDD;
  font-weight: 400;
}

.topbar .spacer { flex: 1; }

.topbar .who {
  font-size: 12px;
  color: #C7CEDD;
  text-align: left;
}

.topbar .who b { color: #fff; }

.logout-btn {
  background: transparent;
  border: 1px solid #3A4A6B;
  color: #E8ECF4;
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.logout-btn:hover { background: var(--navy-mid); }

/* ---------- Login screen ---------- */

.login-wrap {
  min-height: calc(100vh - 74px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-card .balance-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
}

.login-card h2 {
  margin: 0 0 6px;
  font-size: 19px;
}

.login-card p.sub {
  margin: 0 0 22px;
  font-size: 13px;
  color: var(--ink-soft);
}

.role-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  background: var(--parchment);
  border-radius: var(--radius);
  padding: 4px;
}

.role-tab {
  flex: 1;
  padding: 9px 0;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
}

.role-tab.active {
  background: var(--navy-deep);
  color: #fff;
}

.field {
  margin-bottom: 14px;
  text-align: right;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 5px;
}

.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--parchment);
}

.field input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.btn-primary {
  background: var(--navy-deep);
  color: #fff;
  width: 100%;
}
.btn-primary:hover { background: var(--navy-mid); }

.btn-gold {
  background: var(--gold);
  color: #3A2A0B;
}
.btn-gold:hover { filter: brightness(1.05); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--ink);
}
.btn-ghost:hover { background: var(--parchment); }

.error-msg {
  color: var(--status-red);
  font-size: 12.5px;
  margin-top: 10px;
}

/* ---------- Dashboard layout ---------- */

.app-body {
  display: flex;
  min-height: calc(100vh - 74px);
}

.sidebar {
  width: 210px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 16px 10px;
  flex-shrink: 0;
}

.nav-item {
  display: block;
  width: 100%;
  text-align: right;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 2px;
}

.nav-item:hover { background: var(--parchment); }
.nav-item.active { background: var(--gold-soft); color: var(--ink); }

.main {
  flex: 1;
  padding: 22px 26px;
  max-width: 1100px;
}

.panel-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 4px;
}

.panel-sub {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 18px;
}

/* ---------- Cards / summary ---------- */

.summary-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.summary-card .label {
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.summary-card .value {
  font-size: 22px;
  font-weight: 700;
}

.summary-card.green .value { color: var(--status-green); }
.summary-card.red .value { color: var(--status-red); }
.summary-card.blue .value { color: var(--status-blue); }

/* ---------- Toolbar / filters ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.toolbar select, .toolbar input {
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--surface);
}

.toolbar .spacer { flex: 1; }

/* ---------- Table ---------- */

.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

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

.data-table th {
  text-align: right;
  background: var(--parchment);
  color: var(--ink-soft);
  font-weight: 500;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #FAF9F5; }

/* Balance gauge - the signature element: a small inline bar showing
   required vs declared hours, colored by status. */
.balance-cell { display: flex; align-items: center; gap: 8px; }

.balance-bar {
  width: 64px;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  position: relative;
  overflow: hidden;
}

.balance-bar .fill {
  position: absolute;
  top: 0; bottom: 0;
  right: 0;
  border-radius: 3px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  min-width: 34px;
  justify-content: center;
}

.status-pill.balanced { background: var(--status-green-bg); color: var(--status-green); }
.status-pill.deficit { background: var(--status-red-bg); color: var(--status-red); }
.status-pill.surplus { background: var(--status-blue-bg); color: var(--status-blue); }

.profile-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}
.profile-btn:hover { background: var(--parchment); }

/* ---------- Charts ---------- */

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}

.chart-card h4 {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 500;
}

/* ---------- Cards list (position holders) ---------- */

.holder-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.holder-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.holder-card .name { font-weight: 600; font-size: 14px; }
.holder-card .role { font-size: 12px; color: var(--gold); margin: 2px 0 8px; }
.holder-card .meta { font-size: 12px; color: var(--ink-soft); line-height: 1.6; }

/* ---------- Modal (profile / add / edit) ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 24, 48, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 22px;
  max-width: 480px;
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
}

.modal-card h3 {
  margin: 0 0 14px;
  font-size: 16px;
}

.modal-close {
  float: left;
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: var(--ink-soft);
}

.kv-row {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.kv-row .k { color: var(--ink-soft); }
.kv-row .v { font-weight: 500; }

/* ---------- Loading / empty ---------- */

.loading, .empty-state {
  padding: 30px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
}

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
  .app-body { flex-direction: column; }
  .sidebar {
    width: 100%;
    display: flex;
    overflow-x: auto;
    border-left: none;
    border-bottom: 1px solid var(--border);
    gap: 4px;
  }
  .nav-item { white-space: nowrap; width: auto; }
  .main { padding: 16px; }
  .summary-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid, .holder-grid { grid-template-columns: 1fr; }
  .topbar .who { display: none; }
  .data-table { font-size: 12px; }
}
