:root {
  --brand-900: #0a1930;
  --brand-800: #12233c;
  --brand-700: #1b3252;
  --brand-600: #2a4a72;
  --brand-500: #375f8c;
  --brand-100: #eaeef4;
  --gold: #b6902e;
  --gold-dark: #8f6f22;
  --gold-light: #f5ecd2;
  --accent: var(--gold);
  --ink: #23262d;
  --muted: #6b6357;
  --line: #e3ddd0;
  --bg: #f6f3ec;
  --surface: #ffffff;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(10, 25, 48, .08), 0 1px 1px rgba(10, 25, 48, .05);
  --shadow-md: 0 12px 30px rgba(10, 25, 48, .16);
  --sidebar-w: 260px;
  --font-display: "El Messiri", "Cairo", serif;
}

html, body {
  height: 100%;
}

body {
  font-family: "Cairo", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  margin: 0;
  font-size: 15px;
}

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

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--brand-900), var(--brand-800) 60%, var(--brand-700));
  border-inline-end: 1px solid rgba(255, 255, 255, .06);
  color: #d7dfeb;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transition: margin .2s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.25rem 1.25rem 1rem;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.sidebar-brand .icon {
  width: 26px;
  height: 26px;
  color: var(--gold);
  flex-shrink: 0;
}

.sidebar-nav {
  padding: .75rem .6rem;
  flex: 1;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: .7rem;
  color: #b9c5d6;
  padding: .55rem .75rem;
  border-radius: 6px;
  font-weight: 500;
  font-size: .92rem;
  margin-bottom: .15rem;
  border-inline-start: 3px solid transparent;
  transition: background .15s ease, color .15s ease;
}

.sidebar-nav .nav-link .icon {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  opacity: .85;
}

.sidebar-nav .nav-link:hover {
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.sidebar-nav .nav-link.active {
  background: rgba(182, 144, 46, .14);
  color: #fff;
  border-inline-start-color: var(--gold);
}

.sidebar-nav .nav-link.active .icon {
  opacity: 1;
  color: var(--gold);
}

.sidebar-foot {
  padding: 1rem 1.25rem;
  font-size: .78rem;
  color: #8695ab;
  border-top: 1px solid rgba(255, 255, 255, .1);
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: .85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--brand-900);
  font-size: 1.1rem;
}

.sidebar-toggle {
  display: none;
  border: none;
  background: transparent;
  color: var(--brand-900);
}

.content-area {
  padding: 1.5rem;
  flex: 1;
}

.app-footer {
  padding: 1rem 1.5rem;
  color: var(--muted);
  font-size: .82rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

/* ---------- Icons ---------- */
.icon {
  width: 20px;
  height: 20px;
  vertical-align: -4px;
}

/* ---------- Page header ---------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1.4rem;
  padding-bottom: .9rem;
  border-bottom: 2px solid var(--gold);
}

.page-header h1 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--brand-900);
  margin: 0;
  display: flex;
  align-items: center;
  gap: .55rem;
}

.page-header h1 .icon {
  width: 24px;
  height: 24px;
  color: var(--brand-700);
}

.page-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

/* ---------- Cards ---------- */
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.surface-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.4rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
  color: inherit;
  transition: transform .15s ease, box-shadow .15s ease;
  height: 100%;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  color: inherit;
}

.stat-card .stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--brand-100);
  color: var(--brand-700);
}

.stat-card .stat-icon .icon {
  width: 26px;
  height: 26px;
}

.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--brand-900);
  line-height: 1.1;
}

.stat-card .stat-label {
  color: var(--muted);
  font-size: .85rem;
  font-weight: 600;
}

/* ---------- Tables ---------- */
.table-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table {
  margin: 0;
}

.table thead th {
  background: var(--brand-900);
  color: var(--gold-light);
  font-weight: 700;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .02em;
  border-bottom-width: 2px;
  border-bottom-style: solid;
  border-bottom-color: var(--gold) !important;
  padding: .8rem 1rem;
  white-space: nowrap;
}

.table tbody td {
  padding: .7rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: rgba(182, 144, 46, .07);
}

.table tbody tr.row-warning {
  background: var(--gold-light);
}

.table tbody tr.row-warning:hover {
  background: #efdfab;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.table-search {
  position: relative;
  min-width: 240px;
}

.table-search .icon {
  position: absolute;
  inset-inline-start: .7rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.table-search input {
  padding-inline-start: 2.2rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

/* ---------- Badges ---------- */
.badge-soft {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .3rem .65rem;
  border-radius: 4px;
  font-size: .76rem;
  font-weight: 700;
}

.badge-soft-warning { background: var(--gold-light); color: #7a5c12; }
.badge-soft-success { background: #e2ede4; color: #205c34; }
.badge-soft-danger { background: #f4e1e1; color: #7a2020; }
.badge-soft-neutral { background: #efece4; color: var(--muted); }
.badge-soft-info { background: var(--brand-100); color: var(--brand-700); }

/* ---------- Buttons ---------- */
.btn {
  border-radius: 7px;
  font-weight: 600;
  font-size: .88rem;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
}

.btn .icon {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--brand-800);
  border-color: var(--brand-800);
}

.btn-primary:hover {
  background: var(--brand-900);
  border-color: var(--brand-900);
}

.btn-outline-primary {
  color: var(--brand-700);
  border-color: var(--brand-700);
}

.btn-sm {
  padding: .32rem .65rem;
  font-size: .8rem;
  border-radius: 5px;
}

.btn-icon-group {
  display: flex;
  gap: .35rem;
}

/* ---------- Forms ---------- */
.form-section {
  border-bottom: 1px solid var(--line);
  padding-bottom: .5rem;
  margin-bottom: 1.25rem;
}

.form-section h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand-700);
  margin: 0;
  display: flex;
  align-items: center;
  gap: .4rem;
}

.form-label {
  font-weight: 600;
  font-size: .85rem;
  color: var(--brand-900);
}

.form-control, .form-select {
  border-radius: 7px;
  border-color: var(--line);
  padding: .5rem .75rem;
}

.form-control:focus, .form-select:focus, .form-check-input:focus {
  border-color: var(--brand-600);
  box-shadow: 0 0 0 .2rem rgba(42, 74, 114, .15);
}

.form-check-input:checked {
  background-color: var(--brand-700);
  border-color: var(--brand-700);
}

.form-text {
  font-size: .8rem;
}

/* ---------- Details ---------- */
.detail-list dt {
  font-weight: 600;
  color: var(--muted);
  font-size: .85rem;
  padding-top: .55rem;
  padding-bottom: .55rem;
  border-bottom: 1px solid var(--line);
}

.detail-list dd {
  font-size: .95rem;
  color: var(--ink);
  padding-top: .55rem;
  padding-bottom: .55rem;
  border-bottom: 1px solid var(--line);
}

/* ---------- Auth pages ---------- */
.auth-body {
  background: var(--surface);
  min-height: 100vh;
}

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

/* Decorative brand panel */
.auth-visual {
  flex: 1 1 46%;
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, var(--brand-900), var(--brand-800) 55%, var(--brand-700));
  color: #ece6d4;
  padding: 3rem 3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.auth-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(45deg, rgba(182, 144, 46, .08) 0 1px, transparent 1px 16px),
    repeating-linear-gradient(-45deg, rgba(182, 144, 46, .06) 0 1px, transparent 1px 16px);
}

.auth-visual::after {
  content: "";
  position: absolute;
  width: 460px;
  height: 460px;
  border-radius: 50%;
  inset-inline-end: -160px;
  top: -180px;
  background: rgba(255, 255, 255, .03);
  pointer-events: none;
}

.auth-visual-brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: .65rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
}

.auth-visual-brand .icon {
  width: 30px;
  height: 30px;
  color: var(--gold);
}

.auth-visual-heading {
  position: relative;
  z-index: 1;
}

.auth-visual-heading h1 {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: .75rem;
}

.auth-visual-heading p {
  color: #c9bfa0;
  font-size: .95rem;
  max-width: 380px;
}

.auth-feature-list {
  position: relative;
  z-index: 1;
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: .9rem;
}

.auth-feature-list li {
  display: flex;
  align-items: center;
  gap: .7rem;
  font-size: .88rem;
  color: #d9d2bb;
}

.auth-feature-list .icon-badge {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, .08);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-feature-list .icon-badge .icon {
  width: 17px;
  height: 17px;
  color: var(--gold);
}

.auth-visual-foot {
  position: relative;
  z-index: 1;
  font-size: .78rem;
  color: #7c8aa0;
}

/* Form panel */
.auth-form-area {
  flex: 1 1 54%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  animation: auth-fade-in .45s ease;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2.25rem 2rem;
}

.auth-card-head {
  margin-bottom: 1.75rem;
}

.auth-card-head .auth-mobile-brand {
  display: none;
  align-items: center;
  gap: .5rem;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--brand-900);
  margin-bottom: 1.25rem;
}

.auth-card-head .auth-mobile-brand .icon {
  width: 24px;
  height: 24px;
  color: var(--brand-600);
}

.auth-card-head h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--brand-900);
  margin-bottom: .35rem;
}

.auth-card-head p {
  color: var(--muted);
  font-size: .87rem;
  margin: 0;
}

.auth-alert {
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  background: #f4e1e1;
  color: #7a2020;
  border-radius: 7px;
  padding: .7rem .85rem;
  font-size: .85rem;
  margin-bottom: 1.1rem;
}

.auth-alert .icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  margin-top: .1rem;
}

.auth-field {
  margin-bottom: 1.1rem;
}

.auth-field .input-icon-group {
  position: relative;
}

.auth-field .input-icon-group .field-icon {
  position: absolute;
  inset-inline-start: .85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--muted);
  pointer-events: none;
}

.auth-field .input-icon-group .form-control {
  padding-inline-start: 2.5rem;
}

.auth-field .input-icon-group .toggle-password {
  position: absolute;
  inset-inline-end: .5rem;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--muted);
  padding: .3rem;
  line-height: 1;
  display: flex;
}

.auth-field .input-icon-group .toggle-password .icon {
  width: 17px;
  height: 17px;
}

.auth-field .input-icon-group.has-toggle .form-control {
  padding-inline-end: 2.5rem;
}

.auth-remember {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.4rem;
}

.auth-remember .form-check {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .85rem;
  color: var(--muted);
}

.auth-submit {
  width: 100%;
  justify-content: center;
  padding: .65rem 1rem;
  font-size: .95rem;
}

@keyframes auth-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 899.98px) {
  .auth-visual {
    display: none;
  }

  .auth-form-area {
    flex: 1 1 100%;
  }

  .auth-card-head .auth-mobile-brand {
    display: flex;
  }
}

/* ---------- Generic form alert (validation summary, etc.) ---------- */
.form-alert {
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  background: #f4e1e1;
  color: #7a2020;
  border-radius: 7px;
  padding: .7rem .85rem;
  font-size: .85rem;
  margin-bottom: 1.1rem;
}

.form-alert .icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  margin-top: .1rem;
}

.form-alert ul {
  margin: 0;
  padding-inline-start: 1.1rem;
}

.form-alert.validation-summary-valid {
  display: none;
}

/* ---------- File upload dropzone ---------- */
.file-drop {
  position: relative;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 1.5rem 1rem;
  text-align: center;
  transition: border-color .15s ease, background .15s ease;
}

.file-drop:hover,
.file-drop.dragover {
  border-color: var(--brand-600);
  background: var(--brand-100);
}

.file-drop input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-drop .file-drop-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--brand-800);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto .6rem;
}

.file-drop .file-drop-icon .icon {
  width: 19px;
  height: 19px;
}

.file-drop .file-drop-text {
  font-size: .88rem;
  color: var(--ink);
  font-weight: 600;
}

.file-drop .file-drop-hint {
  font-size: .78rem;
  color: var(--muted);
  margin-top: .2rem;
}

.file-drop .file-drop-name {
  margin-top: .5rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--brand-700);
}

.current-file-badge {
  display: flex;
  align-items: center;
  gap: .6rem;
  background: var(--brand-100);
  border-radius: 7px;
  padding: .6rem .85rem;
  margin-bottom: .75rem;
}

.current-file-badge .icon {
  width: 18px;
  height: 18px;
  color: var(--brand-700);
  flex-shrink: 0;
}

.current-file-badge span {
  font-size: .85rem;
  color: var(--brand-700);
  font-weight: 600;
}

/* ---------- Mobile ---------- */
@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    z-index: 1040;
    margin-inline-start: calc(-1 * var(--sidebar-w));
  }

  .sidebar.show {
    margin-inline-start: 0;
    box-shadow: var(--shadow-md);
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .content-area {
    padding: 1rem;
  }
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 25, 48, .4);
  z-index: 1030;
}

.sidebar-backdrop.show {
  display: block;
}

/* ---------- Custom date picker (locale-independent, always English) ---------- */
.dp-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6357' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4.5' width='18' height='16' rx='2'/%3E%3Cpath d='M3 9.5h18'/%3E%3Cpath d='M8 3v3M16 3v3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left .65rem center;
  padding-inline-start: 2.2rem;
  cursor: pointer;
  text-align: right;
}

.dp-popup {
  position: absolute;
  z-index: 1050;
  width: 250px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: .75rem;
  font-size: .85rem;
}

.dp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .5rem;
}

.dp-label {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--brand-900);
}

.dp-nav {
  border: none;
  background: transparent;
  color: var(--brand-700);
  font-size: 1.1rem;
  line-height: 1;
  width: 26px;
  height: 26px;
  border-radius: 6px;
}

.dp-nav:hover {
  background: var(--brand-100);
}

.dp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}

.dp-weekday {
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
  padding: .25rem 0;
}

.dp-day {
  border: none;
  background: transparent;
  color: var(--ink);
  border-radius: 6px;
  padding: .35rem 0;
  font-size: .82rem;
}

.dp-day:hover {
  background: var(--brand-100);
}

.dp-day.is-today {
  font-weight: 700;
  color: var(--brand-700);
}

.dp-day.is-selected {
  background: var(--brand-800);
  color: #fff;
}

.dp-footer {
  display: flex;
  justify-content: space-between;
  margin-top: .5rem;
  padding-top: .5rem;
  border-top: 1px solid var(--line);
}

.dp-link {
  border: none;
  background: transparent;
  color: var(--brand-700);
  font-size: .78rem;
  font-weight: 600;
  padding: .2rem .4rem;
}

.dp-link:hover {
  text-decoration: underline;
}
