:root {
  --bg: #f3f4f6;
  --bg-card: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --accent: #0f766e;
  --accent-soft: #ecfdf5;
  --danger: #b91c1c;
}

/* Base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body.app {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body.app--rtl {
  direction: rtl;
  font-family: "Tajawal", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

/* Layout */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}

.app-header__logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-header__logo-img {
  width: 32px;
  height: 32px;
}

.app-header__brand-name {
  font-weight: 600;
  font-size: 16px;
}

.app-header__brand-tagline {
  font-size: 12px;
  color: var(--muted);
}

.app-body {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 52px);
}

body.app--rtl .app-body {
  grid-template-columns: minmax(0, 1fr) 220px;
}

.app-sidebar {
  background: #f9fafb;
  border-inline-end: 1px solid var(--border);
  padding: 16px 14px;
}

body.app--rtl .app-sidebar {
  border-inline-end: none;
  border-inline-start: 1px solid var(--border);
}

.app-main {
  padding: 20px 24px 32px;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
}

/* Sidebar */

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.side-nav__section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 2px;
}

.side-nav__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  text-decoration: none;
  font-size: 13px;
  color: #374151;
}

.side-nav__item:hover {
  background: #e5e7eb;
}

.side-nav__icon {
  font-size: 15px;
}

.side-nav__card {
  margin-top: 8px;
  padding: 10px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
}

.side-nav__card-title {
  font-size: 13px;
  font-weight: 600;
}

.side-nav__card-text {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.side-nav__card-foot {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 6px;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: #e5e7eb;
  color: #111827;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ecfdf5;
}

.btn--primary:hover {
  background: #0d665f;
}

.btn--ghost {
  background: #ffffff;
  border-color: var(--border);
  color: var(--muted);
}

.btn--ghost:hover {
  background: #f3f4f6;
}

.btn--danger {
  background: #fee2e2;
  border-color: #fecaca;
  color: var(--danger);
}

.btn--danger:hover {
  background: #fecaca;
}

.btn--xs {
  padding: 3px 9px;
  font-size: 11px;
}

/* Hero */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 16px;
  margin-bottom: 18px;
}

.hero__content {
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 18px 18px 16px;
}

.hero__badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11px;
}

.hero__title {
  margin: 10px 0 4px;
  font-size: 22px;
}

.hero__subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.hero__actions {
  margin-top: 14px;
}

.hero__side {
  display: flex;
  align-items: stretch;
}

.stat-card {
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 14px 14px 12px;
  width: 100%;
}

.stat-card__label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.stat-card__value {
  margin-top: 8px;
  font-size: 26px;
  font-weight: 600;
}

/* Cards */

.card {
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.card--padded {
  padding: 16px 18px 20px;
}

.card__header {
  padding: 14px 18px 8px;
  border-bottom: 1px solid #e5e7eb;
}

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

.card__subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.card__eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #9ca3af;
}

/* Tables */

.table-wrapper {
  padding: 12px 16px 14px;
}

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

.data-table th,
.data-table td {
  padding: 8px 6px;
  border-bottom: 1px solid #e5e7eb;
}

.data-table thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-align: left;
}

.data-table__primary {
  display: flex;
  flex-direction: column;
}

.data-table__title {
  font-size: 13px;
}

.data-table__subtitle {
  font-size: 11px;
  color: #9ca3af;
}

.data-table__actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

.data-table__cell--right {
  text-align: right;
}

.data-table--compact th,
.data-table--compact td {
  padding: 6px 6px;
}

/* Empty */

.empty-state {
  padding: 20px 18px;
  font-size: 13px;
  color: var(--muted);
}

/* Forms */

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 2fr);
  gap: 18px;
  padding-top: 8px;
}

.form-grid__main,
.form-grid__side {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-label {
  font-size: 13px;
}

.form-label__hint {
  font-size: 11px;
  color: var(--muted);
  margin-inline-start: 4px;
}

.form-input {
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 7px 9px;
  font-size: 13px;
  outline: none;
  width: 100%;
}

.form-input--textarea {
  min-height: 80px;
  resize: vertical;
}

.form-input--code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 12px;
}

.form-input--sm {
  padding: 5px 8px;
  font-size: 12px;
}

.form-input:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 1px #bfdbfe;
}

.form-subsection {
  margin-top: 8px;
}

.form-subsection__title {
  margin: 0 0 2px;
  font-size: 15px;
}

.form-subsection__subtitle {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--muted);
}

.form-help {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}

.form-actions {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

/* Side panels */

.side-panel {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f9fafb;
  padding: 10px 10px 12px;
}

.side-panel__header {
  margin-bottom: 8px;
}

.side-panel__title {
  margin: 0;
  font-size: 14px;
}

.side-panel__subtitle {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* Items blocks (products, timeline, attachments) */

.items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.item-block {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  padding: 8px 8px 10px;
}

.item-block__row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.item-block__row--stacked {
  flex-direction: column;
  align-items: stretch;
}

.item-block__hint {
  font-size: 11px;
  color: var(--muted);
}

.item-block__current {
  font-size: 11px;
  color: #9ca3af;
  margin-bottom: 4px;
}

/* Proposal internal */

.page--proposal .card {
  padding: 16px 18px 20px;
}

.proposal-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 10px;
}

.proposal-header__eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.proposal-header__title {
  margin: 4px 0 3px;
  font-size: 20px;
}

.proposal-header__subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.proposal-header__meta {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.proposal-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.proposal-body {
  margin-top: 8px;
  font-size: 14px;
  color: #374151;
}

.proposal-body h1,
.proposal-body h2,
.proposal-body h3 {
  color: var(--text);
}

.proposal-body h1 {
  font-size: 20px;
  margin-top: 0;
  margin-bottom: 8px;
}

.proposal-body h2 {
  font-size: 17px;
  margin-top: 16px;
  margin-bottom: 6px;
}

.proposal-body h3 {
  font-size: 15px;
  margin-top: 12px;
  margin-bottom: 4px;
}

.proposal-body p {
  margin: 4px 0 9px;
}

.proposal-body ul {
  margin: 4px 0 10px 18px;
}

body.app--rtl .proposal-body ul {
  margin: 4px 18px 10px 0;
}

.proposal-body li {
  margin-bottom: 4px;
}

.proposal-separator {
  margin: 14px 0 10px;
  border: 0;
  border-top: 1px solid var(--border);
}

.attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 6px;
}

.attachment-card {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f9fafb;
  overflow: hidden;
}

.attachment-card img {
  width: 100%;
  display: block;
  max-height: 150px;
  object-fit: cover;
}

.attachment-card figcaption {
  padding: 6px 8px;
  font-size: 12px;
}

.attachment-card__caption {
  color: var(--muted);
  margin-top: 2px;
}

/* Responsive */

@media (max-width: 960px) {
  .app-body {
    grid-template-columns: minmax(0, 1fr);
  }
  .app-sidebar {
    display: none;
  }
  .app-main {
    padding-inline: 16px;
  }
  .hero {
    grid-template-columns: minmax(0, 1fr);
  }
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
