@import url("https://fonts.googleapis.com/css2?family=Bodoni+Moda:ital,opsz,wght@0,6..96,400;0,6..96,500;1,6..96,400&family=Manrope:wght@300;400;500;600;700&family=El+Messiri:wght@400;500;600&family=IBM+Plex+Sans+Arabic:wght@300;400;500;600&display=swap");

/* ==========================================================================
   Oud Notes — e-invoicing workspace
   Modern Blue: ivory, royal blue #2e3a8c, deep navy #1c2461.
   ========================================================================== */

:root {
  --radius: 6px;
  --font-display: "Bodoni Moda", "Times New Roman", serif;
  --font-body: "Manrope", "Helvetica Neue", Arial, sans-serif;
  --font-ar-display: "El Messiri", "Noto Naskh Arabic", serif;
  --font-ar-body: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;

  --bg: #f6f4ee;
  --surface: #ffffff;
  --surface-2: #eceef7;
  --ink: #111214;
  --muted: #6b707c;
  --accent: #2e3a8c;
  --accent-hover: #20296b;
  --accent-ink: #ffffff;
  --line: rgba(17, 18, 20, 0.12);
  --sidebar: #1c2461;
  --sidebar-ink: #f4f1e9;
  --shadow: 0 30px 70px -36px rgba(28, 36, 97, 0.34);

  --ok: #2f6f5e;
  --warn: #8a6a1f;
  --danger: #9b2c2c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.55;
}

html[lang="ar"] body { font-family: var(--font-ar-body); }

body { min-height: 100vh; }

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px clamp(18px, 4vw, 48px);
  background: var(--sidebar);
  color: var(--sidebar-ink);
  border-bottom: 3px solid var(--accent);
}

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

.brand-lockup {
  display: flex;
  flex-direction: column;
  gap: 7px;
  text-decoration: none;
  color: inherit;
}

.brand-lockup img {
  display: block;
  height: 30px;
  width: auto;
  filter: invert(1);
}

.brand-lockup span {
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.6;
}

html[lang="ar"] .brand-lockup span {
  letter-spacing: 0;
  text-transform: none;
  font-size: 10px;
}

.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.who { font-size: 12px; opacity: 0.75; letter-spacing: 0.02em; }

button {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.ghost {
  background: transparent;
  color: var(--sidebar-ink);
  border-color: rgba(244, 241, 233, 0.28);
  padding: 7px 12px;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.ghost:hover { background: rgba(244, 241, 233, 0.1); }

.ghost.dark {
  color: var(--ink);
  border-color: var(--line);
  background: var(--surface);
}
.ghost.dark:hover { border-color: var(--accent); color: var(--accent); }
.ghost.small { padding: 5px 10px; font-size: 11px; }

/* --------------------------------------------------------------------------
   Tabs
   -------------------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 2px;
  padding: 0 clamp(18px, 4vw, 48px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 15px 18px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

html[lang="ar"] .tab {
  letter-spacing: 0;
  text-transform: none;
  font-size: 13px;
}

.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */
main {
  width: min(1120px, calc(100% - 36px));
  margin: 0 auto;
  padding: 40px 0 72px;
}

.hero { max-width: 760px; margin-bottom: 30px; }

.kicker {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: clamp(30px, 4.4vw, 46px);
  line-height: 1.04;
  letter-spacing: -0.03em;
  font-weight: 400;
}

html[lang="ar"] h1 {
  font-family: var(--font-ar-display);
  letter-spacing: 0;
  line-height: 1.3;
}

h2 { margin: 0 0 8px; font-size: 15px; letter-spacing: 0.01em; }
h3 { margin: 0 0 8px; font-size: 14px; letter-spacing: 0.01em; }

.intro { margin: 0; color: var(--muted); font-size: 15px; max-width: 66ch; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.card h2 { margin: 0 0 8px; font-size: 14px; letter-spacing: 0.01em; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.card p + p { margin-top: 8px; }
.card.wide { margin-top: 16px; }

.dot {
  position: absolute;
  top: 20px;
  inset-inline-end: 20px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(47, 111, 94, 0.12);
}

.ok { color: var(--ok) !important; font-weight: 600; }
.warn { color: var(--warn) !important; font-weight: 600; }
.muted { color: var(--muted) !important; font-size: 13px; }
.small { font-size: 12px; }

.checklist { margin: 12px 0 0; padding-inline-start: 20px; color: var(--muted); font-size: 14px; }
.checklist li + li { margin-top: 6px; }

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 4px 0 14px;
}
.section-head h2 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.02em;
}
html[lang="ar"] .section-head h2 { font-family: var(--font-ar-display); letter-spacing: 0; }
.section-head p { margin: 0; color: var(--muted); font-size: 13px; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: start;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
html[lang="ar"] .table th { letter-spacing: 0; text-transform: none; font-size: 11px; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td small { display: block; margin-top: 2px; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}
.span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.field input:focus { outline: 2px solid var(--surface-2); border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.form-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.primary {
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
}
.primary:hover { background: var(--accent-hover); }
.primary:disabled { opacity: 0.6; cursor: default; }

/* --------------------------------------------------------------------------
   Detail and totals
   -------------------------------------------------------------------------- */
.detail { margin-top: 18px; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 14px 0 18px;
}
.detail-grid > div { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.label {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
html[lang="ar"] .label { letter-spacing: 0; text-transform: none; font-size: 11px; }

.totals { margin: 16px 0 10px; margin-inline-start: auto; width: min(320px, 100%); font-size: 13px; }
.totals > div { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; color: var(--muted); }
.totals .grand {
  border-top: 1px solid var(--line);
  margin-top: 6px;
  padding-top: 10px;
  color: var(--ink);
  font-size: 15px;
}

/* --------------------------------------------------------------------------
   Messages and XML
   -------------------------------------------------------------------------- */
.error {
  margin-top: 20px;
  padding: 12px 14px;
  border: 1px solid rgba(155, 44, 44, 0.25);
  background: rgba(155, 44, 44, 0.06);
  color: var(--danger);
  border-radius: var(--radius);
  font-size: 14px;
}
.error-inline { color: var(--danger); font-size: 13px; }

.preview-banner {
  margin: 0 0 18px;
  padding: 10px 14px;
  border: 1px solid rgba(46, 58, 140, 0.22);
  background: var(--surface-2);
  color: var(--accent);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.notice-line {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid rgba(138, 106, 31, 0.25);
  background: rgba(138, 106, 31, 0.06);
  color: var(--warn);
  border-radius: var(--radius);
  font-size: 13px;
}

.events { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.event {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
}
.event span { color: var(--muted); }

.xml-preview {
  max-height: 420px;
  overflow: auto;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--sidebar);
  color: var(--sidebar-ink);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  direction: ltr;
  text-align: left;
}

a.ghost { text-decoration: none; display: inline-flex; align-items: center; }

[hidden] { display: none !important; }

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .section-head { flex-direction: column; }
}

@media (max-width: 560px) {
  .topbar { align-items: flex-start; }
  .actions { width: 100%; justify-content: flex-start; }
  .who { display: none; }
  .brand-lockup img { height: 26px; }
}
