/* An internal business tool: quiet, dense, fast. No decoration for its own sake. */

:root {
  --ink: #16191d;
  --muted: #6b7280;
  --line: #dfe3e8;
  --bg: #f4f5f7;
  --card: #ffffff;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --warn-bg: #fff8e6;
  --warn-line: #e0b44a;
  --error-bg: #fdeceb;
  --error-line: #d14343;
  --info-bg: #eef4ff;
  --info-line: #7aa2e8;
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 "Segoe UI", Tahoma, "Iranian Sans", system-ui, sans-serif;
}

main { max-width: 1400px; margin: 0 auto; padding: 24px 20px 64px; }

/* --- top bar --- */
.bar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; padding: 0 20px; background: var(--card);
  border-bottom: 1px solid var(--line);
}
.bar nav, .bar-left { display: flex; align-items: center; gap: 18px; }
.bar a { color: var(--ink); text-decoration: none; padding: 14px 0; font-size: 14px; }
.bar a:hover { color: var(--accent); }
.bar .brand { font-weight: 700; }
.tag {
  font-size: 12px; padding: 2px 8px; border-radius: 99px;
  background: var(--info-bg); color: #1e40af; border: 1px solid var(--info-line);
}
.tag-muted { background: #f1f2f4; color: var(--muted); border-color: var(--line); }

/* --- cards --- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; margin-bottom: 20px;
}
.card.narrow { max-width: 420px; }
.centered { display: flex; justify-content: center; padding-top: 8vh; }
.centered-text { text-align: center; margin: 0 auto; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 26px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* --- the review screen: source beside the table --- */
.split { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(0, 1.6fr); gap: 20px; align-items: start; }
.split .source { position: sticky; top: 20px; }
.source-image {
  width: 100%; border: 1px solid var(--line); border-radius: 4px; display: block;
}
@media (max-width: 1000px) {
  .split { grid-template-columns: 1fr; }
  .split .source { position: static; }
}

/* --- forms --- */
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
input, select {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 4px; background: #fff;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 620px) { .row { grid-template-columns: 1fr; } }
.field small { display: block; margin-top: 4px; font-weight: 400; }

fieldset.vat { border: 1px solid var(--line); border-radius: 4px; padding: 12px 14px; margin: 0; }
fieldset.vat legend { font-weight: 600; font-size: 14px; padding: 0 6px; }
.choice { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; margin: 6px 0; }
.choice input { width: auto; margin-top: 5px; }

button, a.primary, a.secondary {
  font: inherit; cursor: pointer; border-radius: 4px; padding: 10px 18px;
  border: 1px solid transparent; text-decoration: none; display: inline-block;
}
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.primary:hover { filter: brightness(1.08); }
.primary:disabled { opacity: .6; cursor: progress; }
.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.secondary:hover { border-color: var(--accent); color: var(--accent); }
a.link, button.link {
  background: none; border: none; color: var(--accent); padding: 10px 4px; cursor: pointer;
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 20px; }

/* --- upload --- */
.dropzone {
  display: block; border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 40px 20px; text-align: center; cursor: pointer; background: #fafbfc;
  margin-bottom: 18px; font-weight: 400;
}
.dropzone:hover { border-color: var(--accent); background: var(--info-bg); }
.dropzone input { display: none; }
.dropzone-text small { display: block; color: var(--muted); margin-top: 6px; }
#preview { display: none; max-height: 320px; margin: 16px auto 0; border: 1px solid var(--line); }
#filename { display: block; margin-top: 10px; font-size: 13px; }

/* --- tables --- */
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
.grid th, .grid td { border: 1px solid var(--line); padding: 7px 9px; text-align: right; font-size: 14px; }
.grid thead th { background: #f7f8fa; font-size: 13px; white-space: nowrap; }
.grid tbody tr:hover { background: #fbfcfd; }
.grid .index { text-align: center; color: var(--muted); width: 44px; }
.grid .nowrap { white-space: nowrap; }
.grid .nowrap a { margin-left: 8px; }
.grid .address { max-width: 340px; font-size: 13px; color: var(--muted); }
.grid tr.inactive td { opacity: .5; }
.editable input { border-color: transparent; background: transparent; padding: 5px 6px; }
.editable input:hover { border-color: var(--line); background: #fff; }
.editable .num { text-align: left; font-variant-numeric: tabular-nums; }
tr.flagged td { background: var(--warn-bg); }
tr.finding-row td { border-top: none; background: var(--warn-bg); padding-top: 0; }
.finding { font-size: 13px; color: #8a5a00; }

.summary th, .summary td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--line); }
.summary th { color: var(--muted); font-weight: 600; width: 45%; }
.summary td { font-variant-numeric: tabular-nums; }
.summary tr.grand th, .summary tr.grand td { font-size: 17px; font-weight: 700; border-bottom: none; }
.summary.small th, .summary.small td { font-size: 13px; padding: 4px 8px; }

/* --- messages --- */
.alert { padding: 11px 14px; border-radius: 4px; margin-bottom: 16px; font-size: 14px; border: 1px solid; }
.alert-error { background: var(--error-bg); border-color: var(--error-line); color: #8c2020; }
.alert-warn  { background: var(--warn-bg);  border-color: var(--warn-line);  color: #7a4d00; }
.alert-info  { background: var(--info-bg);  border-color: var(--info-line);  color: #1e3a8a; }
code { background: #f1f2f4; padding: 1px 5px; border-radius: 3px; font-size: 13px; }
