:root {
  --ink: #111827;
  --muted: #667085;
  --line: #d7dee8;
  --panel: #ffffff;
  --page: #eef2f6;
  --green: #087456;
  --green-soft: #e4f4ef;
  --red: #b42318;
  --red-soft: #fee4e2;
  --amber: #b45309;
  --amber-soft: #fff4d6;
  --blue: #1d4f91;
  --blue-soft: #e8f1ff;
  --black: #0b1220;
  --nav: #111827;
  --nav-soft: #1f2937;
  --shadow: 0 16px 36px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  background:
    linear-gradient(120deg, rgba(11, 18, 32, 0.9), rgba(8, 116, 86, 0.72)),
    url("https://images.unsplash.com/photo-1503376780353-7e6692767b70?auto=format&fit=crop&w=1800&q=80") center/cover;
}

.login-brand {
  color: white;
  padding: clamp(32px, 6vw, 80px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.72);
  font-weight: 800;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
}

.login-brand h1 {
  margin: 28px 0 14px;
  max-width: 680px;
  font-size: clamp(36px, 5vw, 64px);
  line-height: 1;
}

.login-brand p {
  max-width: 560px;
  margin: 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 18px;
  line-height: 1.6;
}

.login-panel-wrap {
  display: grid;
  align-items: center;
  padding: clamp(24px, 5vw, 72px);
}

.login-panel {
  width: min(100%, 460px);
  margin-left: auto;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.auth-stack {
  width: min(100%, 520px);
  margin-left: auto;
  display: grid;
  gap: 14px;
}

.auth-stack .login-panel {
  width: 100%;
}

.register-panel {
  padding-top: 22px;
}

.login-panel h2,
.section-title h2 {
  margin: 0;
  color: var(--black);
}

.login-panel p {
  color: var(--muted);
  line-height: 1.5;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field span,
.form-grid label span {
  font-size: 13px;
  font-weight: 700;
  color: #39465a;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 10px 12px;
  border-radius: 6px;
  min-height: 40px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #7aa2dc;
  box-shadow: 0 0 0 3px rgba(29, 79, 145, 0.12);
  outline: none;
}

textarea {
  resize: vertical;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 9px 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.primary-btn {
  background: #0b6f54;
  color: white;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.18);
}

.secondary-btn {
  background: var(--blue-soft);
  border-color: #c9d7f4;
  color: var(--blue);
}

.ghost-btn {
  background: white;
  border-color: var(--line);
  color: var(--ink);
}

.danger-btn {
  background: var(--red-soft);
  color: var(--red);
  border-color: #efc5c3;
}

.demo-logins {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.demo-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  background: #f6f8fb;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 292px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, var(--nav), #0c1424);
  color: white;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar .brand-line {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar .brand-mark {
  width: 40px;
  height: 40px;
  font-size: 14px;
}

.sidebar h2 {
  margin: 0;
  font-size: 18px;
}

.sidebar p {
  margin: 2px 0 0;
  color: rgba(255, 255, 255, 0.62);
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 3px;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  padding-right: 2px;
}

.nav button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: rgba(255, 255, 255, 0.76);
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 9px 10px;
  font-size: 14px;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.08);
  color: white;
}

.user-box {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding-top: 16px;
  display: grid;
  gap: 10px;
}

.content {
  min-width: 0;
  padding: 22px 24px 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.15;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

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

.stat-card,
.panel,
.table-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.stat-card {
  padding: 14px;
  border-left: 3px solid #1d4f91;
}

.clickable {
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.clickable:hover,
.clickable:focus {
  border-color: #9bb6e8;
  box-shadow: 0 10px 24px rgba(18, 31, 48, 0.12);
  outline: none;
  transform: translateY(-1px);
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.stat-card strong {
  display: block;
  margin-top: 7px;
  font-size: 23px;
  line-height: 1.1;
}

.stat-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.72fr) minmax(480px, 1.28fr);
  gap: 16px;
  align-items: start;
}

.bank-bottom-grid {
  margin-top: 16px;
}

.client-detail-band {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 16px;
}

.client-detail-grid {
  display: grid;
  gap: 16px;
}

.client-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fbfcfe;
}

.client-detail-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.client-detail-header h3 {
  margin: 0;
}

.client-detail-header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.client-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.client-stats span {
  min-width: 118px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}

.client-stats small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.client-stats strong {
  display: block;
  margin-top: 4px;
}

.panel {
  padding: 16px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.section-title p {
  margin: 5px 0 0;
  color: var(--muted);
}

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

.form-grid label {
  display: grid;
  gap: 7px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.table-panel {
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

tbody tr:hover {
  background: #f8fbff;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f3f6fa;
  color: #39465a;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
}

td {
  font-size: 13px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status.paid,
.status.received,
.status.approved {
  background: var(--green-soft);
  color: var(--green);
}

.status.pending,
.status.partial {
  background: var(--amber-soft);
  color: var(--amber);
}

.status.overdue,
.status.rejected {
  background: var(--red-soft);
  color: var(--red);
}

.status.open {
  background: var(--blue-soft);
  color: var(--blue);
}

.status.in-progress,
.status.labour-supply,
.status.own-equipment,
.status.medium {
  background: var(--blue-soft);
  color: var(--blue);
}

.status.completed,
.status.deposit,
.status.low {
  background: var(--green-soft);
  color: var(--green);
}

.status.blocked,
.status.urgent,
.status.withdrawal,
.status.high {
  background: var(--red-soft);
  color: var(--red);
}

.status.fuel,
.status.equipment-rental,
.status.hired-from-supplier,
.status.material-supply,
.status.supplier,
.status.materials {
  background: var(--amber-soft);
  color: var(--amber);
}

.status.transport-supply,
.status.subcontract-work,
.status.other-commission {
  background: var(--green-soft);
  color: var(--green);
}

.status.maintenance,
.status.permit-fine {
  background: var(--red-soft);
  color: var(--red);
}

.status.salary,
.status.petty-cash,
.status.rent,
.status.utilities {
  background: var(--blue-soft);
  color: var(--blue);
}

.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.quick-list {
  display: grid;
  gap: 10px;
}

.profit-summary {
  margin-bottom: 16px;
}

.quick-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  padding: 12px;
  border-radius: 7px;
  background: #fbfcfe;
}

.quick-item small {
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 20, 24, 0.54);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 10;
}

.modal {
  width: min(720px, 100%);
  max-height: min(760px, 92vh);
  overflow: auto;
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: var(--black);
  color: white;
  padding: 12px 14px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  z-index: 11;
}

.hidden {
  display: none !important;
}

@media (max-width: 1080px) {
  .app-shell,
  .login-shell,
  .work-grid {
    grid-template-columns: 1fr;
  }

  .login-brand {
    min-height: 420px;
  }

  .login-panel {
    margin: 0 auto;
  }

  .sidebar {
    position: static;
    gap: 14px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .nav {
    max-height: none;
  }
}

@media (max-width: 680px) {
  .content,
  .sidebar,
  .login-panel-wrap,
  .login-brand {
    padding: 16px;
  }

  .topbar,
  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .stats-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .client-detail-header {
    flex-direction: column;
  }

  .client-stats {
    width: 100%;
    justify-content: stretch;
  }

  .client-stats span {
    flex: 1 1 140px;
  }
}
