/*
  Montrei web client.

  Every horizontal measure is a CSS logical property (inline-start, inline-end, padding-inline, margin-inline,
  inset-inline, text-align: start), never left or right, so the same rules lay the page out left to right in
  English and right to left in Persian. The dir attribute on <html> and on .shell decides which.
*/

:root {
    --ink: #1f1a2b;
    --ink-soft: #5b5470;
    --paper: #ffffff;
    --wash: #f5f3f9;
    --line: #dcd7e6;
    --brand: #5b2a86;
    --brand-strong: #44206a;
    --brand-wash: #efe7f7;
    --good: #1f6f43;
    --good-wash: #e6f4ec;
    --stop: #a4262c;
    --stop-wash: #fbeaea;
    --focus: #1a5fb4;
    --radius: 6px;
    font-family: "Segoe UI", Tahoma, "Noto Sans", Arial, sans-serif;
    font-size: 15px;
    color: var(--ink);
    background: var(--wash);
}

*, *::before, *::after { box-sizing: border-box; }

body { margin: 0; }

h1 { font-size: 1.5rem; margin-block: 0 1rem; }
h2 { font-size: 1.15rem; margin-block: 1.5rem 0.75rem; }

a { color: var(--brand); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.loading { padding: 2rem; color: var(--ink-soft); }

.skip-link {
    position: absolute;
    inset-inline-start: 0.5rem;
    inset-block-start: -3rem;
    background: var(--paper);
    padding: 0.5rem 1rem;
    z-index: 10;
}
.skip-link:focus { inset-block-start: 0.5rem; }

/* Shell */
.shell { min-height: 100vh; display: flex; flex-direction: column; }

.shell-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.6rem 1.25rem;
    background: var(--brand);
    color: #fff;
}
.brand { font-size: 1.25rem; font-weight: 600; letter-spacing: 0.02em; }
.brand-client { opacity: 0.9; }
.shell-header .spacer { flex: 1; }
.shell-header .operator { font-size: 0.9rem; opacity: 0.95; }

.language-switch { display: inline-flex; gap: 0.25rem; }
.language-switch button {
    border: 1px solid rgba(255, 255, 255, 0.6);
    background: transparent;
    color: #fff;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius);
    cursor: pointer;
}
.language-switch button[aria-pressed="true"] { background: #fff; color: var(--brand); }

.shell-body { display: flex; flex: 1; min-height: 0; }

.nav {
    flex: 0 0 13rem;
    background: var(--paper);
    border-inline-end: 1px solid var(--line);
    padding-block: 1rem;
}
.nav ul { list-style: none; margin: 0; padding: 0; }
.nav a {
    display: block;
    padding: 0.55rem 1.25rem;
    color: var(--ink);
    text-decoration: none;
    border-inline-start: 3px solid transparent;
}
.nav a:hover { background: var(--wash); }
.nav a.active { border-inline-start-color: var(--brand); background: var(--brand-wash); font-weight: 600; }
.nav .nav-group { padding: 0.75rem 1.25rem 0.25rem; font-size: 0.8rem; color: var(--ink-soft); text-transform: uppercase; }

.shell-main { flex: 1; padding: 1.5rem; min-width: 0; }

/* Cards and panels */
.panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-block-end: 1rem;
}

.sign-in {
    max-width: 30rem;
    margin: 3rem auto;
}
.sign-in .lead { color: var(--ink-soft); margin-block: 0 1.25rem; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 0.3rem; margin-block-end: 0.9rem; }
.field label { font-weight: 600; font-size: 0.9rem; }
.field input, .field select, .field textarea {
    font: inherit;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    color: inherit;
}
.field .hint { font-size: 0.85rem; color: var(--ink-soft); }
.field-invalid input, .field-invalid select, .field-invalid textarea { border-color: var(--stop); }
.field-error { color: var(--stop); font-size: 0.85rem; }

.check { display: flex; align-items: flex-start; gap: 0.5rem; margin-block-end: 1rem; }
.check input { margin-block-start: 0.25rem; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 0 1.25rem; }

/* Buttons */
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-block: 0.5rem 1rem; }
.button {
    font: inherit;
    padding: 0.45rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--brand);
    background: var(--brand);
    color: #fff;
    cursor: pointer;
}
.button:hover { background: var(--brand-strong); }
.button:disabled { opacity: 0.55; cursor: not-allowed; }
.button-quiet { background: var(--paper); color: var(--brand); }
.button-quiet:hover { background: var(--brand-wash); }
.button-danger { background: var(--stop); border-color: var(--stop); }
.shell-header .button-quiet { border-color: rgba(255, 255, 255, 0.6); background: transparent; color: #fff; }

/* Messages */
.message { padding: 0.75rem 1rem; border-radius: var(--radius); margin-block-end: 1rem; }
.message-stop { background: var(--stop-wash); color: var(--stop); border: 1px solid #f0c4c6; }
.message-good { background: var(--good-wash); color: var(--good); border: 1px solid #bfe3cd; }
.message-info { background: var(--brand-wash); color: var(--brand-strong); border: 1px solid var(--line); }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { padding: 0.5rem 0.75rem; text-align: start; border-block-end: 1px solid var(--line); white-space: nowrap; }
table.grid th { background: var(--wash); font-size: 0.85rem; color: var(--ink-soft); }
table.grid td.number, table.grid th.number { text-align: end; font-variant-numeric: tabular-nums; }
table.grid tbody tr:hover { background: var(--wash); }
table.grid tbody tr.selected { background: var(--brand-wash); }
table.grid button.link { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; font: inherit; text-decoration: underline; }
table.grid button.delete-line { padding-block: 0.15rem; }
iframe.invoice-pdf {
    display: block;
    width: 100%;
    height: 80vh;
    border: 1px solid var(--line);
    background: var(--paper);
}

iframe.invoice-pdf[hidden] {
    display: none;
}

.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 0.75rem; margin-block-end: 1rem; }
.toolbar .field { margin: 0; }

.summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0.75rem; margin-block-end: 1rem; }
.summary .tile { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 1rem; }
.summary .tile .label { font-size: 0.85rem; color: var(--ink-soft); }
.summary .tile .value { font-size: 1.2rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Invoices: the four totals, and an unpaid invoice due more than three days ago (said in words, not by colour alone) */
.totals { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0.75rem; margin-block-end: 1rem; }
.total-card { display: flex; flex-direction: column; gap: 0.25rem; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 1rem; }
.total-card .total-label { font-size: 0.85rem; color: var(--ink-soft); }
.total-card .total-value { font-size: 1.2rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.total-card .total-currency { margin-inline-start: 0.35rem; font-size: 0.85rem; color: var(--ink-soft); }
table.grid tbody tr.overdue { background: var(--stop-wash); }
table.grid tbody tr.failed { background: var(--stop-wash); }
table.grid tbody tr.archived td { color: var(--ink-soft); }
.archived-tag { display: inline-block; margin-inline-start: 0.5rem; padding: 0 0.4rem; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink-soft); font-size: 0.8rem; font-weight: 600; }
table.grid td.content { max-inline-size: 24rem; overflow-wrap: anywhere; }
.toolbar .check.recent { margin-block-end: 0; align-items: center; }
.overdue-tag { display: inline-block; margin-inline-start: 0.5rem; padding: 0 0.4rem; border: 1px solid var(--stop); border-radius: var(--radius); color: var(--stop); font-size: 0.8rem; font-weight: 600; }

/* Dialog */
.dialog-backdrop { position: fixed; inset: 0; background: rgba(20, 12, 30, 0.45); display: flex; align-items: center; justify-content: center; z-index: 20; }
.dialog { background: var(--paper); border-radius: var(--radius); padding: 1.25rem 1.5rem; max-width: 32rem; width: calc(100% - 2rem); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); }
.dialog h2 { margin-block-start: 0; }

.pdf-frame { width: 100%; height: 75vh; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }

#blazor-error-ui {
    display: none;
    position: fixed;
    inset-block-end: 0;
    inset-inline: 0;
    padding: 0.75rem 1.25rem;
    background: var(--stop-wash);
    color: var(--stop);
    z-index: 30;
}
#blazor-error-ui .dismiss { cursor: pointer; margin-inline-start: 1rem; }

/* The invoices matrix: the four currencies, then subtotal rows and the grand total set apart from the months. */
.note { color: var(--ink-soft); margin-block: -0.5rem 1rem; }
.currencies ul { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.currencies a { display: inline-block; padding: 0.25rem 0.75rem; border: 1px solid var(--line); border-radius: var(--radius); }
.currencies a.current { border-color: var(--brand); background: var(--brand-wash); font-weight: 600; }
.matrix .subtotal th, .matrix .subtotal td { font-weight: 600; background: var(--wash); }
.matrix .grand-total th, .matrix .grand-total td { font-weight: 700; border-block-start: 2px solid var(--line); }
.matrix th.label { text-align: start; }

@media (max-width: 720px) {
    .shell-body { flex-direction: column; }
    .nav { flex-basis: auto; border-inline-end: 0; border-block-end: 1px solid var(--line); }
}
