/* AP / AR Operations Console — console.css
   Shared styles for the AP and AR console pages. Consumes shared design tokens
   from theme.css (load theme.css first): indigo `primary` accent reserved for
   agent identity + primary actions, slate `surface` neutrals, soft shadows. */

body {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--surface-900);
    background: var(--surface-50);
}

/* ===== Header / nav ===== */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 60px;
    background: #fff;
    color: var(--surface-900);
    border-bottom: 1px solid var(--surface-200);
    box-shadow: var(--shadow-soft);
    position: sticky;
    top: 0;
    z-index: 50;
}
header h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 10px;
}
header h1::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    box-shadow: var(--shadow-glow);
}
header nav { display: flex; align-items: center; gap: 4px; }
header nav a {
    color: var(--surface-500);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 7px 12px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    border-radius: var(--btn-radius);
    transition: color .15s, background .15s;
}
header nav a:hover { color: var(--surface-900); background: var(--surface-100); }
header nav a.active { color: var(--primary-700); background: var(--primary-50); font-weight: 600; }

/* ===== Health strip ===== */
#health-strip {
    display: flex;
    gap: 20px;
    align-items: center;
    padding: 12px 24px;
    background: #fff;
    border-bottom: 1px solid var(--surface-200);
    font-size: 13px;
    color: var(--surface-600);
    flex-wrap: wrap;
}
#health-strip span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--surface-50);
    border: 1px solid var(--surface-200);
    border-radius: 999px;
}
#health-strip .dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--surface-300);
    vertical-align: middle;
    flex: 0 0 auto;
}
#health-strip .dot.ok { background: var(--erp-synced); }
#health-strip .dot.bad { background: var(--erp-error); }
#health-strip strong { color: var(--surface-900); font-weight: 600; }
#health-strip .muted { background: none; border: none; padding: 0; }

/* ===== Layout ===== */
main {
    padding: 24px 24px 60px;
    max-width: 1400px;
    margin: 0 auto;
    animation: fade-in 200ms ease-out;
}

.tabbar {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--surface-200);
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.tabbar button {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 11px 16px;
    margin-bottom: -1px;
    font-size: 14px;
    font-weight: 500;
    color: var(--surface-500);
    cursor: pointer;
    border-radius: var(--btn-radius) var(--btn-radius) 0 0;
    transition: color .15s, background .15s;
}
.tabbar button:hover { color: var(--surface-900); background: var(--surface-100); }
.tabbar button.active {
    color: var(--primary-700);
    border-bottom-color: var(--primary-600);
    font-weight: 600;
}

.panel { display: none; }
.panel.active { display: block; animation: fade-in 200ms ease-out; }

/* ===== Cards & grid ===== */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}
.card {
    background: #fff;
    border: 1px solid var(--surface-200);
    border-radius: var(--card-radius);
    padding: 18px;
    box-shadow: var(--shadow-soft);
    transition: box-shadow .15s, border-color .15s;
}
.card:hover { box-shadow: var(--card-shadow-hover); border-color: var(--surface-300); }
.card h3 {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--surface-500);
}
.card .metric {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--surface-900);
    font-variant-numeric: tabular-nums;
}
.card .sub { font-size: 12px; color: var(--surface-500); margin-top: 4px; }

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 16px;
    gap: 12px;
    flex-wrap: wrap;
}
.section-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--surface-900);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    min-height: 40px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: var(--primary-600);
    border: none;
    border-radius: var(--btn-radius);
    cursor: pointer;
    transition: background .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--primary-700); box-shadow: var(--shadow-soft-md); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: #fff; color: var(--surface-700); border: 1px solid var(--surface-200); box-shadow: none; }
.btn.secondary:hover { background: var(--surface-100); border-color: var(--surface-300); }
.btn.success { background: var(--erp-synced); }
.btn.success:hover { background: #047857; }
.btn.danger { background: var(--erp-error); }
.btn.danger:hover { background: #b91c1c; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

/* Optional agent-action button (primary + sparkle) — opt in via .btn.agent */
.btn.agent::before { content: "\2728"; font-size: 13px; line-height: 1; }

/* ===== Tables ===== */
table.data {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--surface-200);
    border-radius: var(--card-radius);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}
table.data th, table.data td {
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid var(--surface-100);
    font-size: 13px;
    vertical-align: top;
}
table.data th {
    background: var(--surface-50);
    color: var(--surface-500);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.05em;
}
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: var(--primary-50); }
table.data tr:last-child td { border-bottom: none; }

/* ===== Badges (legacy color names kept for JS; remapped to tokens) ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.5;
}
.badge.green { background: var(--st-approved-bg); color: var(--st-approved-fg); }
.badge.amber { background: var(--st-needs-review-bg); color: var(--st-needs-review-fg); }
.badge.red   { background: var(--st-rejected-bg); color: var(--st-rejected-fg); }
.badge.blue  { background: var(--st-agent-processing-bg); color: var(--st-agent-processing-fg); }
.badge.gray  { background: var(--surface-100); color: var(--surface-600); }

/* ===== Misc ===== */
.muted { color: var(--surface-500); }
.empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--surface-500);
    background: #fff;
    border: 1px solid var(--surface-200);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-soft);
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

input.inp, select.inp, textarea.inp {
    padding: 9px 12px;
    min-height: 40px;
    font-size: 13px;
    border: 1px solid var(--surface-200);
    border-radius: var(--btn-radius);
    background: #fff;
    color: var(--surface-900);
    font-family: inherit;
    box-shadow: var(--shadow-soft);
    transition: border-color .15s, box-shadow .15s;
}
input.inp:focus, select.inp:focus, textarea.inp:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgb(99 102 241 / .18);
}
input.inp::placeholder, textarea.inp::placeholder { color: var(--surface-400); }

.note {
    background: var(--st-needs-review-bg);
    border: 1px solid #fde68a;
    color: var(--st-needs-review-fg);
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 20px;
    line-height: 1.5;
}
.note code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: rgba(146, 64, 14, 0.1);
    padding: 1px 5px;
    border-radius: 4px;
}

/* ===== Toast (portal-style, bottom-right, JS-driven) ===== */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
}
.toast {
    padding: 12px 18px 12px 16px;
    border-radius: 10px;
    color: var(--surface-900);
    background: #fff;
    font-size: 14px;
    box-shadow: var(--shadow-soft-lg);
    border: 1px solid var(--surface-200);
    border-left: 4px solid var(--surface-400);
    animation: slide-up 300ms ease-out;
}
.toast.error   { border-left-color: var(--erp-error); }
.toast.info    { border-left-color: var(--primary-600); }
.toast.success { border-left-color: var(--erp-synced); }

/* ===== Dropzone (Overview → Submit Invoice) ===== */
.dropzone {
    border: 2px dashed var(--surface-300);
    border-radius: var(--card-radius);
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    background: var(--surface-50);
    transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--primary-400); background: var(--primary-50); }
.dropzone.drag { border-color: var(--primary-600); background: var(--primary-100); }
.dropzone .dz-icon { font-size: 32px; margin-bottom: 8px; }
.dropzone .sub { margin-top: 6px; }
