/* ============================================================
   Rosinad Invoicing — stylesheet
   Primary: #ED1C24  Text-dark: #272727  Body: #4a4a4a
   BG: #ffffff  Content: #f5f5f5
   ============================================================ */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --red:    #2C9200;
    --dark:   #272727;
    --body:   #4a4a4a;
    --bg:     #ffffff;
    --surface:#f5f5f5;
    --border: #e0e0e0;
    --shadow: 0 1px 4px rgba(0,0,0,.08);
    --radius: 4px;
    --font: BlinkMacSystemFont, -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;
}

html, body {
    height: 100%;
}

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--body);
    background: var(--bg);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a {
    color: var(--red);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* ── Header ─────────────────────────────────────────────── */

.site-header {
    background: var(--bg);
    border-bottom: 2px solid var(--red);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-logo a {
    display: flex;
    align-items: center;
    text-decoration: none;
}
.header-logo img {
    height: 48px;
    width: auto;
    display: block;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 20px;
    list-style: none;
}

.header-nav a {
    color: var(--dark);
    font-size: 14px;
    font-weight: 500;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
    transition: border-color .15s, color .15s;
    text-decoration: none;
}
.header-nav a:hover,
.header-nav a.active {
    color: var(--red);
    border-bottom-color: var(--red);
}

.header-nav form button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--dark);
    font-size: 14px;
    font-weight: 500;
    padding: 4px 0;
    font-family: var(--font);
    border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s;
}
.header-nav form button:hover {
    color: var(--red);
    border-bottom-color: var(--red);
}

/* ── Main layout ─────────────────────────────────────────── */

.site-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
    width: 100%;
}

.page-with-sidebar {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    max-width: 1500px;
    margin: 0 auto;
    padding: 32px 24px;
    width: 100%;
}

/* ── Sidebar ─────────────────────────────────────────────── */

.sidebar {
    width: 190px;
    flex-shrink: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.sidebar-title {
    background: var(--red);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 10px 14px;
}

.sidebar-body {
    padding: 14px;
}

.sidebar-body label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 4px;
    margin-top: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.sidebar-body label:first-of-type {
    margin-top: 0;
}

.sidebar-body select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    background: var(--bg);
    color: var(--body);
    font-family: var(--font);
}
.sidebar-body select[multiple] {
    height: 120px;
}

/* ── Content area ────────────────────────────────────────── */

.content-area {
    flex: 1;
    min-width: 0;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--dark);
}

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
    display: inline-block;
    padding: 7px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-family: var(--font);
    transition: opacity .15s;
    text-decoration: none;
    line-height: 1.4;
}
.btn:hover {
    opacity: .88;
    text-decoration: none;
}

.btn-primary {
    background: var(--red);
    color: #fff;
}
.btn-secondary {
    background: var(--surface);
    color: var(--dark);
    border: 1px solid var(--border);
}
.btn-warning {
    background: #e67e22;
    color: #fff;
}
.btn-danger {
    background: #c0392b;
    color: #fff;
    border: 1px solid #a93226;
}
.btn-danger:hover { background: #a93226; }
.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}
.btn-apply {
    width: 100%;
    margin-top: 14px;
    text-align: center;
    background: var(--red);
    color: #fff;
}

/* ── Table ───────────────────────────────────────────────── */

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

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    background: var(--surface);
    color: var(--dark);
    font-weight: 700;
    text-align: left;
    padding: 8px 10px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background .1s;
}
tbody tr:last-child {
    border-bottom: none;
}
tbody tr:hover {
    background: #fafafa;
}
tbody tr:nth-child(even) {
    background: #f9f9f9;
}
tbody tr:nth-child(even):hover {
    background: #f5f5f5;
}

td {
    padding: 8px 10px;
    vertical-align: middle;
}

.paid-badge {
    color: var(--red);
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.number-link {
    color: #000;
    font-weight: 700;
    text-decoration: none;
}
.number-link:hover { text-decoration: underline; }

/* ── PDF / file icon ─────────────────────────────────────── */

.file-icon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: #000;
    font-weight: 700;
}
.file-icon:hover {
    text-decoration: underline;
}

.file-icon svg {
    width: 20px;
    height: 20px;
    fill: #ED1C24;
    flex-shrink: 0;
}

/* ── Forms ───────────────────────────────────────────────── */

.form-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    max-width: 560px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 5px;
}

.form-control {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--body);
    font-family: var(--font);
    background: var(--bg);
    transition: border-color .15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--red);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}
.form-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--red);
    cursor: pointer;
}
.form-check label {
    font-size: 14px;
    cursor: pointer;
    margin: 0;
}

.form-hint {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.current-file {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    margin-bottom: 8px;
    font-size: 13px;
}

/* ── Alert / error ───────────────────────────────────────── */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 18px;
    font-size: 13px;
    border: 1px solid transparent;
}
.alert-error {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #991b1b;
}
.alert-success {
    background: #f0fdf4;
    border-color: #86efac;
    color: #166534;
}

/* ── Login page ──────────────────────────────────────────── */

.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 40px 24px;
}

.login-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 2px 12px rgba(0,0,0,.08);
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}
.login-logo img {
    height: 52px;
}

.login-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--dark);
    text-align: center;
    margin-bottom: 24px;
}

/* ── Account page ────────────────────────────────────────── */

.account-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 28px;
    max-width: 480px;
}

.account-row {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    gap: 12px;
}
.account-row:last-child {
    border-bottom: none;
}
.account-label {
    font-weight: 600;
    color: var(--dark);
    width: 140px;
    flex-shrink: 0;
}
.account-value {
    color: var(--body);
}

.role-badge {
    display: inline-block;
    background: var(--red);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    margin-right: 4px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* ── Invoice view detail ─────────────────────────────────── */

.detail-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 28px;
    max-width: 640px;
    margin-bottom: 24px;
}

.detail-row {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    gap: 12px;
}
.detail-row:last-child {
    border-bottom: none;
}
.detail-label {
    font-weight: 600;
    color: var(--dark);
    width: 140px;
    flex-shrink: 0;
}

/* ── Status badge ────────────────────────────────────────── */

.status-active   { color: #27ae60; font-weight: 600; }
.status-inactive { color: #e74c3c; font-weight: 600; }

/* ── Footer ──────────────────────────────────────────────── */

.site-footer {
    border-top: 1px solid var(--border);
    padding: 16px 24px;
    text-align: center;
    font-size: 12px;
    color: #999;
    background: var(--surface);
}

/* ── Utilities ───────────────────────────────────────────── */

.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex  { display: flex; }
.gap-8 { gap: 8px; }
.flex-wrap { flex-wrap: wrap; }

/* ── Drop zone ───────────────────────────────────────────── */

.drop-zone {
    border: 2px dashed var(--red);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 1.5rem;
}
.drop-zone:hover,
.drop-zone.drag-over {
    background: #f0fff0;
}
.drop-zone-prominent {
    padding: 3rem 2rem;
}
.drop-zone-inner .drop-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
}
.drop-hint {
    color: #999;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* ── Quick panel ─────────────────────────────────────────── */

.quick-panel {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.quick-panel h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 1rem;
}
.extract-status {
    margin-bottom: 1rem;
    color: #666;
    font-size: 0.9rem;
    min-height: 1.2em;
}
.extract-status.success { color: #2e7d32; }
.extract-status.error   { color: #c62828; }

/* Public upload page */
.upload-page {
    max-width: 600px;
    margin: 60px auto;
    padding: 0 24px;
}
.upload-page h1 {
    font-size: 24px;
    margin-bottom: 12px;
    color: var(--dark);
}
.upload-subtitle {
    color: #666;
    margin-bottom: 32px;
    line-height: 1.5;
}
.upload-field {
    margin-bottom: 14px;
}
.upload-field label {
    display: block;
    font-weight: 500;
    margin-bottom: 4px;
    font-size: 13px;
    color: var(--dark);
}

/* Public invoice status page */
.status-page {
    max-width: 480px;
    margin: 60px auto;
    padding: 0 24px;
    text-align: center;
}
.status-circle {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    margin: 40px auto 48px;
}
.status-circle-paid    { background: #22c55e; box-shadow: 0 0 60px 10px rgba(34,197,94,.45); }
.status-circle-pending { background: #f9a825; box-shadow: 0 0 60px 10px rgba(249,168,37,.45); }
.status-circle-missing { background: #ef4444; box-shadow: 0 0 60px 10px rgba(239,68,68,.45); }
.status-circle-rejected { background: #ef4444; box-shadow: 0 0 60px 10px rgba(239,68,68,.45); }
.status-title {
    font-size: 28px;
    margin: 0 0 8px;
    color: var(--dark);
}
.status-subtitle {
    color: #666;
    margin-bottom: 32px;
}
.status-details {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    text-align: left;
}
.status-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.status-detail-row:last-child { border-bottom: none; }
.status-detail-row span { color: #666; }
.rejected-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}
tr.row-rejected { opacity: 0.55; }
tr.row-rejected td { text-decoration: line-through; }
tr.row-rejected td:first-child, tr.row-rejected td:last-child { text-decoration: none; }
