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

:root {
  --bg: #07111f;
  --bg-soft: #101b2e;
  --panel: #14233a;
  --panel-2: #182b44;
  --border: #2b4163;
  --text: #f5f2e8;
  --muted: #9fb1c6;
  --gold: #c8a24a;
  --gold-soft: #e8c96a;
  --danger: #d96a58;
  --success: #74b96d;
  --warning: #d8a24b;
}

* { box-sizing: border-box; }
html {
  font-size: 90%;
}
body {
  margin: 0;
  font-family: 'Cairo', 'Tajawal', sans-serif;
  font-size: 1rem;
  background: linear-gradient(135deg, var(--bg), #0d1626 70%);
  color: var(--text);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea {
  font: inherit;
}

dialog {
  border: none;
  padding: 0;
  background: transparent;
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.dialog {
  width: min(100%, 640px);
  max-width: 640px;
  max-height: calc(100vh - 40px);
  border-radius: 24px;
  background: rgba(18, 30, 49, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.dialog-form {
  display: grid;
  gap: 20px;
  padding: 24px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.dialog-header .eyebrow {
  margin: 0;
  font-size: 14px;
  letter-spacing: 1px;
}

.dialog-close {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 28px;
  cursor: pointer;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  transition: background 0.2s ease;
  line-height: 42px;
  text-align: center;
}

.dialog-close:hover {
  background: rgba(255,255,255,0.08);
}

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

.form-field {
  display: grid;
  gap: 8px;
}

.form-field.full-width {
  grid-column: 1 / -1;
}

.form-field span {
  color: var(--muted);
  font-size: 13px;
}

input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(18, 30, 49, 0.9);
  color: var(--text);
}

textarea {
  resize: vertical;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.dialog-actions .button {
  min-width: 120px;
  color: var(--text);
}

.clientHover {
  transition: all 0.3s;
}

.clientHover:hover {
  background-color: #162842c8;
}

.late-client-row {
  background-color: rgba(217, 106, 88, 0.18);
}

.late-client-row:hover {
  background-color: rgba(217, 106, 88, 0.28);
}

@media (max-width: 840px) {
  .toolbar {
    grid-template-columns: 1fr;
  }

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

  .dialog {
    width: min(100%, 100vw - 24px);
    border-radius: 20px;
  }

  .dialog-form {
    padding: 18px;
  }

  .dialog-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .sidebar {
    width: 100%;
    position: static;
  }

  .app-shell {
    flex-direction: column;
  }

  .main-content {
    padding: 18px 16px 24px;
  }
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 234px;
  background: rgba(8, 15, 28, 0.95);
  border-left: 1px solid var(--border);
  padding: 22px 16px;
  display: fixed;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background-color: #011139;
  color: var(--bg);
  font-weight: 800;
  font-size: 20px;
  border-style: solid;
  border-color: var(--border);
  border-width: 2px;
  box-sizing: content-box;
}
.brand-mark img {
  scale: 0.82;
}
.brand h2 {
  margin: 0;
  font-size: 18px;
}
.brand p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 18px;
}
.nav-link {
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--muted);
  transition: all 0.2s ease;
}
.nav-link:hover,
.nav-link.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--gold);
}

.sidebar-footer {
  margin-top: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-top: 160px;
}
.profile-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--panel-2);
  color: var(--gold-soft);
  font-weight: 700;
}
.profile-card strong { display: block; }
.profile-card span { font-size: 12px; color: var(--muted); }
.secondary-link {
  display: inline-block;
  font-size: 13px;
  color: var(--gold-soft);
}

.main-content {
  flex: 1;
  padding: 24px 27px 31px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--gold-soft);
  font-size: 12px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
}
.topbar h1 {
  margin: 0;
  font-size: 24px;
}

.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
}
.button.primary {
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  color: var(--bg);
  font-weight: 700;
}
.button.secondary {
  background: var(--panel);
  color: var(--text);
  border-color: var(--border);
}

.button.danger {
  background: linear-gradient(135deg, #d96a58, #c94b36);
  color: #fff;
  font-weight: 700;
}

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

.card,
.panel {
  background: rgba(20, 35, 58, 0.95);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.16);
}
.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-weight: 700;
}
.metric {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.metric .label { color: var(--muted); font-size: 13px; }
.metric .value { font-size: 28px; font-weight: 800; }
.metric .value.danger { color: var(--danger); }
.metric .value.success { color: var(--success); }

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 12px 10px;
  text-align: right;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  white-space: nowrap;
}
.clientHover { cursor: pointer; }
.clientHover:hover { background: rgba(255,255,255,0.02); }
th { color: var(--muted); font-size: 12px; }

.status-pill {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.status-new { background: #203450; color: #95b7f1; }
.status-contacted { background: #1b3b4a; color: #7ed0db; }
.status-viewing { background: #2d2352; color: #b9a9f7; }
.status-won { background: #173725; color: #92db91; }
.status-lost { background: #4b2321; color: #f0a195; }

/* New status aliases (reuse colors from existing statuses) */
.status-followup { background: #2d2352; color: #b9a9f7; }
.status-booked { background: #2d2352; color: #b9a9f7; }
.status-signed { background: #173725; color: #92db91; }
.status-noanswer { background: #4b2321; color: #f0a195; }
.status-probable { background: #1b3b4a; color: #7ed0db; }
.status-postponed { background: #1b3b4a; color: #7ed0db; }

.progress-list { display: grid; gap: 12px; }
.progress-row { display: grid; gap: 6px; }
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
}
.progress-track {
  height: 8px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-soft), var(--gold));
}
.progress-fill.green { background: linear-gradient(90deg, var(--success), #93d38e); }

.toolbar {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  grid-template-columns: 1fr .6fr .6fr;
}
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold-soft); }

.timeline {
  display: grid;
  gap: 10px;
}
.timeline-item {
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.timeline-item strong { display: block; margin-bottom: 4px; }
.timeline-item span { color: var(--muted); font-size: 12px; }

.work-shift-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  margin-bottom: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.work-shift-card > div { display: grid; gap: 4px; }
.work-duration { font-size: 28px; letter-spacing: 1px; color: var(--gold); }
.work-shift-card form { margin: 0; }

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.calendar-nav a {
  text-decoration: none;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}
.day-name, .day-cell {
  border-radius: 12px;
  padding: 10px;
  min-height: 90px;
}
.day-name {
  text-align: center;
  color: var(--muted);
  font-weight: 700;
  min-height: auto;
}
.day-cell {
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.day-cell.active {
  border-color: var(--gold-soft);
  box-shadow: inset 0 0 0 1px rgba(232,201,106,0.2);
}
.day-cell .date { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.appointment-chip {
  display: block;
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 8px;
  background: rgba(200,162,74,0.15);
  color: var(--gold-soft);
  margin-top: 4px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(circle at top right, rgba(200,162,74,0.16), transparent 36%), var(--bg);
}
.login-card {
  width: min(420px, 100%);
  background: rgba(20,35,58,0.96);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 24px 50px rgba(0,0,0,0.25);
}

.logOut {
  background-color: #0d1827;
  border-color: #1f3553;
  border-style: solid;
  border-radius: 10px;
  border-width: 1.5px;
  padding: 5px;
  padding-left: 10px;
  padding-right: 10px;
}

.login-card h1 { margin: 10px 0 6px; font-size: 24px; }
.login-card p { margin: 0 0 20px; color: var(--muted); }
.login-card .button { width: 100%; justify-content: center; margin-top: 8px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }

@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; border-left: 0; border-bottom: 1px solid var(--border); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .main-content { padding: 18px 16px 24px; }
}
