/* Written by hand so the app needs no CSS build step. Colours are those of
   the marketing site, www.einvoices.ae. */

:root {
    --bg: #f9fafb;
    --surface: #ffffff;
    --border: #e5e7eb;
    --text: #111827;
    --text-muted: #4b5563;
    --accent: #0f766e;
    --accent-hover: #0d9488;
    --accent-wash: #f0fdfa;
    --danger: #b42318;
    --danger-bg: #fef3f2;
    --warn: #92400e;
    --warn-bg: #fef3c7;
    --ok: #065f46;
    --ok-bg: #d1fae5;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

[hidden] { display: none !important; }

a { color: var(--accent); }

.container {
    margin: 0 auto;
    max-width: 72rem;
    padding: 0 1.25rem;
}

.muted { color: var(--text-muted); }
.small { font-size: 0.87rem; }

/* Header */
.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.app-header .container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    min-height: 3.5rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

.brand-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
}

.account {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
    color: var(--text-muted);
    font-size: 0.9rem;
}

main { padding-top: 1.5rem; padding-bottom: 3rem; }

h1 { margin: 0 0 0.25rem; font-size: 1.4rem; line-height: 1.25; }
h2 { margin: 0 0 0.5rem; font-size: 1.05rem; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.45rem 0.9rem;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    white-space: nowrap;
}

.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.55; cursor: default; }

.btn-quiet {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

.btn-quiet:hover { background: var(--bg); }

.btn-link {
    padding: 0;
    border: none;
    background: none;
    color: var(--accent);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: underline;
}

/* Cards and notices */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.card-narrow { max-width: 24rem; margin: 3rem auto; }

.notice {
    padding: 0.65rem 0.9rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    margin-bottom: 1rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.notice.error { border-color: #fda29b; background: var(--danger-bg); color: var(--danger); }
.notice.warn { border-color: #fcd34d; background: var(--warn-bg); color: var(--warn); }
.notice.ok { border-color: #6ee7b7; background: var(--ok-bg); color: var(--ok); }

.badge {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    background: #e5e7eb;
    color: var(--text-muted);
    white-space: nowrap;
}

.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--accent-wash); color: var(--accent); }

/* Forms */
label { display: block; margin-bottom: 0.2rem; font-size: 0.87rem; font-weight: 600; }

input, select {
    width: 100%;
    padding: 0.5rem 0.65rem;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid #d1d5db;
    border-radius: 6px;
}

input:focus, select:focus, .btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.field { margin-bottom: 0.85rem; }
.field .hint { margin-top: 0.2rem; font-size: 0.8rem; color: var(--text-muted); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.actions.end { justify-content: flex-end; margin-top: 0.5rem; }

/* Business picker */
.list {
    margin: 0;
    padding: 0;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    max-width: 40rem;
}

.list li + li { border-top: 1px solid var(--border); }

.list li { display: flex; align-items: stretch; }

.list button {
    border: none;
    background: none;
    font: inherit;
    cursor: pointer;
}

.list .business {
    display: flex;
    flex: 1;
    min-width: 0;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem 0.75rem 0.4rem;
    text-align: left;
}

.list .business:hover { background: var(--accent-wash); }

/* The favourite star: grey until chosen. */
.list .star {
    flex-shrink: 0;
    padding: 0 0.5rem 0 1rem;
    font-size: 1.1rem;
    line-height: 1;
    color: #d1d5db;
}

.list .star:hover, .list .star[aria-pressed="true"] { color: #f59e0b; }
.list button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Workspace */
.bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.seller {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem 1.5rem;
}

.seller dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 1rem; }
.seller dt { color: var(--text-muted); }
.seller dd { margin: 0; }

.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }

.tab {
    padding: 0.55rem 0.9rem;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    font: inherit;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
}

.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow-x: auto;
}

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

th, td { padding: 0.6rem 0.9rem; text-align: left; vertical-align: middle; }

th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr + tr td { border-top: 1px solid var(--border); }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.nowrap { white-space: nowrap; }
tr.row-error td { border-top: none; padding-top: 0; }
tr.row-error .notice { margin: 0; }

.empty { padding: 2.5rem 1rem; text-align: center; color: var(--text-muted); }

/* Dialog */
dialog {
    width: 34rem;
    max-width: calc(100vw - 2rem);
    padding: 1.25rem 1.4rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
}

dialog.wide { width: 60rem; }
dialog::backdrop { background: rgba(17, 24, 39, 0.4); }

pre {
    margin: 0 0 1rem;
    padding: 0.9rem;
    max-height: 60vh;
    overflow: auto;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 8px;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.8rem;
    line-height: 1.45;
}

@media (max-width: 34rem) {
    .grid-2 { grid-template-columns: 1fr; }
}
