@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=Noto+Kufi+Arabic:wght@500;600;700&display=swap");

:root {
  --font-main: "IBM Plex Sans Arabic", "Dubai", "Noto Sans Arabic", "Tajawal", "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
  --font-display: "Noto Kufi Arabic", "IBM Plex Sans Arabic", "Dubai", "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
  --font-number: "Segoe UI", "Dubai", "IBM Plex Sans Arabic", Tahoma, Arial, sans-serif;
  --ink: #14171c;
  --ink-soft: #343b46;
  --muted: #68707d;
  --line: #dde3ea;
  --panel: #ffffff;
  --bg: #eef2f6;
  --soft: #f8fafc;
  --accent: #d71920;
  --accent-dark: #a90f16;
  --accent-soft: #fff0f1;
  --success: #0f8a5f;
  --warn: #b45309;
  --sidebar: #12161d;
  --sidebar-2: #1c222c;
  --shadow: 0 14px 34px rgba(20, 23, 28, 0.09);
  --shadow-soft: 0 8px 18px rgba(20, 23, 28, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  background:
    linear-gradient(135deg, rgba(215, 25, 32, 0.05), transparent 30%),
    linear-gradient(315deg, rgba(18, 22, 29, 0.08), transparent 34%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-main);
  font-size: 15px;
  line-height: 1.68;
  letter-spacing: 0;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(215, 25, 32, 0.12), transparent 32%),
    linear-gradient(315deg, rgba(18, 22, 29, 0.16), transparent 36%),
    #eef2f6;
}

.login-screen.hidden {
  display: none;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 26px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-card img {
  width: 180px;
  max-width: 70%;
  justify-self: center;
}

.login-card h2 {
  margin: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 760;
}

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--ink-soft);
  font-weight: 680;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: #b42318;
  font-weight: 700;
  text-align: center;
}

.sidebar {
  min-height: 100vh;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(215, 25, 32, 0.14), transparent 28%),
    var(--sidebar);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: grid;
  grid-template-columns: 96px 1fr;
  align-items: center;
  gap: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.brand-logo {
  width: 96px;
  height: 72px;
  object-fit: contain;
  flex: 0 0 auto;
  background: #fff;
  border-radius: 8px;
  padding: 5px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.16);
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3 {
  margin: 0;
}

.brand h1 {
  font-size: 21px;
  font-family: var(--font-display);
  font-weight: 750;
  line-height: 1.25;
}

.brand p,
.eyebrow {
  color: #aeb8c5;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item,
.ghost-button,
.primary-button,
.text-button {
  border: 0;
  border-radius: 8px;
  min-height: 44px;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.nav-item {
  position: relative;
  color: #d9e3ef;
  background: transparent;
  text-align: right;
  padding: 11px 14px;
  font-weight: 650;
}

.nav-item::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  right: 0;
  width: 3px;
  border-radius: 999px;
  background: transparent;
}

.nav-item.active,
.nav-item:hover {
  background: var(--sidebar-2);
  color: #fff;
}

.nav-item.active::before {
  background: var(--accent);
}

.sidebar-note {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  color: #eef4fb;
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-note strong {
  color: #fff;
}

.sidebar-note span {
  color: #bac6d4;
  line-height: 1.7;
}

.app-shell {
  padding: 30px;
  min-width: 0;
}

.topbar,
.section-toolbar,
.panel-header,
.modal-actions,
.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar {
  justify-content: space-between;
  margin-bottom: 24px;
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(221, 227, 234, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}

.topbar h2 {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 760;
  line-height: 1.25;
  color: var(--ink);
}

.eyebrow {
  color: var(--accent-dark);
  font-weight: 700;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.top-actions select {
  width: 210px;
}

.primary-button {
  background: var(--accent);
  color: #fff;
  padding: 0 18px;
  font-weight: 720;
  box-shadow: 0 10px 20px rgba(215, 25, 32, 0.2);
}

.primary-button:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.ghost-button {
  background: #fff;
  color: var(--ink);
  padding: 0 16px;
  border: 1px solid var(--line);
  font-weight: 700;
}

.ghost-button:hover {
  background: var(--soft);
}

.text-button {
  color: var(--accent-dark);
  background: transparent;
  padding: 0 4px;
  min-height: 32px;
  font-weight: 700;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.stat,
.panel,
.order-card,
.invoice-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.stat {
  position: relative;
  overflow: hidden;
  padding: 20px;
  display: grid;
  gap: 10px;
}

.stat::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), #111827);
}

.stat span {
  color: var(--muted);
  font-weight: 650;
}

.stat strong {
  font-size: 27px;
  font-family: var(--font-number);
  font-weight: 800;
  color: var(--ink);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.55fr);
  gap: 16px;
}

.workflow-panel {
  grid-column: 1 / -1;
}

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

.workflow-steps div {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.workflow-steps strong {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.panel {
  padding: 18px;
}

.panel.plain {
  padding: 0;
  overflow: hidden;
}

.panel-header {
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel h3 {
  font-size: 18px;
  font-family: var(--font-display);
  font-weight: 740;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: right;
  padding: 14px 13px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 720;
  background: var(--soft);
}

td {
  color: var(--ink);
}

tr:hover td {
  background: #fbfcfe;
}

.section-toolbar {
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

input,
textarea,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 13px;
  background: #fff;
  color: var(--ink);
  outline: none;
  font-weight: 500;
  transition: border 160ms ease, box-shadow 160ms ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(215, 25, 32, 0.55);
  box-shadow: 0 0 0 4px rgba(215, 25, 32, 0.1);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.section-toolbar input {
  max-width: 480px;
}

.segmented-control {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented-control button {
  border: 0;
  min-height: 36px;
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink-soft);
  background: transparent;
  font-weight: 720;
}

.segmented-control button.active {
  color: #fff;
  background: var(--accent);
}

.report-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.report-head img {
  width: 150px;
  height: 82px;
  object-fit: contain;
}

.report-head h3 {
  font-size: 24px;
}

.report-stats {
  margin-bottom: 16px;
}

.cards-list,
.stack-list {
  display: grid;
  gap: 12px;
}

.order-card,
.invoice-card,
.stack-item {
  padding: 16px;
}

.order-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.card-actions,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-actions {
  justify-content: flex-end;
}

.order-card:hover,
.invoice-card:hover {
  box-shadow: var(--shadow);
}

.invoice-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.print-button {
  min-width: 92px;
  color: var(--accent-dark);
}

.table-button {
  min-height: 34px;
  padding: 0 12px;
}

.danger-button {
  color: #b42318;
  border-color: #ffd1cc;
}

.danger-button:hover {
  background: #fff1f0;
}

.wide-dialog {
  width: min(980px, calc(100vw - 28px));
}

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

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

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

.settings-grid .panel {
  display: grid;
  gap: 12px;
}

.maintenance-panel {
  border-color: #f3c2bd;
  background: linear-gradient(180deg, #fff, #fff7f6);
}

.settings-grid label {
  display: grid;
  gap: 6px;
  color: var(--ink-soft);
  font-weight: 680;
}

.statement-summary div {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 5px;
}

.statement-summary span {
  color: var(--muted);
  font-weight: 680;
  font-size: 13px;
}

.statement-summary strong {
  font-size: 18px;
  font-family: var(--font-number);
  font-weight: 760;
}

.statement-table {
  max-height: 430px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.info-row td {
  color: var(--muted);
  background: #fbfcfe;
}

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

.card-title strong {
  font-size: 18px;
  font-family: var(--font-display);
  font-weight: 740;
}

.meta {
  color: var(--muted);
  line-height: 1.8;
}

.amount {
  font-size: 21px;
  font-family: var(--font-number);
  font-weight: 800;
  color: var(--accent-dark);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 720;
}

.badge.warn {
  background: #fff4df;
  color: var(--warn);
}

.badge.done {
  background: #e7f7ec;
  color: var(--success);
}

.stack-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #fff;
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  width: min(580px, calc(100vw - 28px));
  box-shadow: 0 24px 80px rgba(12, 18, 28, 0.3);
}

dialog::backdrop {
  background: rgba(17, 24, 39, 0.58);
  backdrop-filter: blur(2px);
}

.modal-form {
  padding: 24px;
  display: grid;
  gap: 14px;
}

.modal-form h3 {
  margin: 0 0 4px;
  font-size: 23px;
  font-family: var(--font-display);
  font-weight: 760;
}

.modal-form label {
  display: grid;
  gap: 6px;
  color: var(--ink-soft);
  font-weight: 680;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.photo-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.photo-strip img {
  width: 72px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: #fff;
}

.modal-actions {
  justify-content: flex-start;
  margin-top: 6px;
}

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

@media (max-width: 980px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    padding: 16px;
  }

  .brand {
    grid-template-columns: 86px 1fr;
  }

  .brand-logo {
    width: 86px;
    height: 62px;
  }

  .nav {
    grid-template-columns: repeat(11, minmax(128px, 1fr));
    overflow-x: auto;
  }

  .sidebar-note {
    display: none;
  }

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

@media (max-width: 680px) {
  body {
    font-size: 14px;
  }

  .app-shell {
    padding: 16px;
  }

  .topbar,
  .section-toolbar,
  .order-card,
  .form-row,
  .report-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar h2 {
    font-size: 26px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .top-actions select {
    width: 100%;
  }

  .stats-grid,
  .content-grid,
  .workflow-steps,
  .settings-grid,
  .statement-summary {
    grid-template-columns: 1fr;
  }

  .section-toolbar input {
    max-width: none;
  }

  .amount {
    text-align: right;
  }
}
