/* ═══════════════════════════════════════════════
   Memeshift Invoice Manager — Stylesheet
   Palette: #FAC946 · #007998 · #F90002 · #333333 · #404040
   Fonts: Lora (display/body) · DM Mono (labels/mono)
═══════════════════════════════════════════════ */

/* ── Custom properties ── */
:root {
    --yellow:   #FAC946;
    --yellow-d: #e8b62e;
    --teal:     #007998;
    --teal-d:   #005f78;
    --red:      #F90002;
    --dark:     #333333;
    --body:     #404040;
    --muted:    #666666;
    --border:   #e2e2e2;
    --bg:       #f7f6f2;
    --white:    #ffffff;

    --font-serif: 'Lora', Georgia, serif;
    --font-mono:  'DM Mono', 'Courier New', monospace;

    --radius:   6px;
    --radius-lg: 10px;
    --shadow:   0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.12);
}

/* ── Reset & base ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html { font-size: 16px; }

body {
    font-family: var(--font-serif);
    font-size: 1rem;
    color: var(--body);
    background: var(--bg);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 {
    font-family: var(--font-serif);
    color: var(--dark);
    font-weight: 700;
    line-height: 1.2;
}

/* ── Utilities ── */
.mono { font-family: var(--font-mono); }
.text-right { text-align: right; }
.text-muted { color: var(--muted); }

/* ════════════════════════════════════════
   LAYOUT
════════════════════════════════════════ */

.site-header {
    background: var(--yellow);
    border-bottom: 3px solid var(--red);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
}

.logo-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: var(--dark);
    color: var(--yellow);
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: 1.1rem;
    border-radius: 4px;
    flex-shrink: 0;
}

.logo-text {
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: 1rem;
    color: var(--dark);
    line-height: 1.1;
}

.logo-text em {
    display: block;
    font-style: italic;
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--dark);
    opacity: 0.7;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.site-nav a {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--dark);
    text-decoration: none;
    letter-spacing: 0.02em;
}
.site-nav a:hover { color: var(--teal-d); }

.nav-logout {
    opacity: 0.6;
    font-size: 0.75rem !important;
}

.site-main {
    min-height: calc(100vh - 120px);
    padding: 2.5rem 0;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.site-footer {
    background: var(--yellow);
    border-top: 3px solid var(--red);
    padding: 0.9rem 1.5rem;
}

.footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--dark);
    opacity: 0.75;
}

.footer-sep { color: var(--red); }

/* ════════════════════════════════════════
   LOGIN PAGE
════════════════════════════════════════ */

body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-wrap {
    width: 100%;
    max-width: 420px;
    padding: 1.5rem;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border-top: 4px solid var(--yellow);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem 2rem;
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.login-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    background: var(--yellow);
    border: 3px solid var(--red);
    color: var(--dark);
    font-family: var(--font-serif);
    font-size: 1.6rem;
    font-weight: 700;
    border-radius: 8px;
    flex-shrink: 0;
}

.login-logo h1 {
    font-size: 1.2rem;
    line-height: 1.1;
}

.login-logo h1 span {
    display: block;
    font-size: 0.8rem;
    font-weight: 400;
    font-style: italic;
    color: var(--muted);
}

/* ════════════════════════════════════════
   COMPONENTS — Buttons
════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    padding: 0.5rem 1.1rem;
    border-radius: var(--radius);
    border: 2px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.15s ease;
    line-height: 1;
}

.btn:hover { text-decoration: none; }

.btn-primary {
    background: var(--teal);
    color: var(--white);
    border-color: var(--teal);
}
.btn-primary:hover {
    background: var(--teal-d);
    border-color: var(--teal-d);
    color: var(--white);
}

.btn-secondary {
    background: var(--dark);
    color: var(--yellow);
    border-color: var(--dark);
}
.btn-secondary:hover {
    background: #222;
    color: var(--yellow);
}

.btn-success {
    background: #1a7a3c;
    color: var(--white);
    border-color: #1a7a3c;
}
.btn-success:hover { background: #145f2f; color: var(--white); }

.btn-ghost {
    background: transparent;
    color: var(--body);
    border-color: var(--border);
}
.btn-ghost:hover {
    background: var(--white);
    border-color: #bbb;
    color: var(--dark);
}

.btn-danger {
    background: var(--red);
    color: var(--white);
    border-color: var(--red);
}
.btn-danger:hover { background: #c90001; color: var(--white); }

.btn-sm {
    font-size: 0.72rem;
    padding: 0.35rem 0.85rem;
}

.btn-lg {
    font-size: 0.85rem;
    padding: 0.7rem 1.5rem;
}

.btn-full { width: 100%; }

/* ════════════════════════════════════════
   COMPONENTS — Forms
════════════════════════════════════════ */

.field {
    margin-bottom: 1.1rem;
}

.field label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.req { color: var(--red); }

.field input[type="text"],
.field input[type="email"],
.field input[type="date"],
.field input[type="number"],
.field input[type="password"],
.field textarea,
.field select,
input[type="text"],
input[type="email"],
input[type="date"],
input[type="number"],
input[type="password"],
textarea,
select {
    width: 100%;
    font-family: var(--font-serif);
    font-size: 0.95rem;
    color: var(--dark);
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 0.55rem 0.75rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    appearance: none;
    -webkit-appearance: none;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(0,121,152,0.12);
}

textarea { resize: vertical; min-height: 80px; }

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.2rem;
    cursor: pointer;
}

/* ── Field row (side by side) ── */
.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ── Alert / flash ── */
.alert {
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    border-left: 4px solid transparent;
}

.alert-success {
    background: #edf7f0;
    border-color: #1a7a3c;
    color: #145f2f;
}

.alert-error {
    background: #fff0f0;
    border-color: var(--red);
    color: #8b0000;
}

/* ════════════════════════════════════════
   DASHBOARD
════════════════════════════════════════ */

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.page-heading h2 {
    font-size: 1.6rem;
    color: var(--dark);
}

.heading-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ── Summary cards ── */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.summary-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border-top: 3px solid var(--border);
    padding: 1.1rem 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.summary-card--paid   { border-top-color: #1a7a3c; }
.summary-card--outstanding { border-top-color: var(--teal); }
.summary-card--overdue { border-top-color: var(--red); }

.summary-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.summary-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--dark);
    line-height: 1;
}

/* ── Filters ── */
.filter-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
    padding: 0.75rem 1rem;
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.filter-label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-right: 0.25rem;
}

.filter-group {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.filter-pill {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    border: 1.5px solid var(--border);
    background: transparent;
    color: var(--muted);
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.filter-pill:hover {
    border-color: var(--teal);
    color: var(--teal);
    text-decoration: none;
}

.filter-pill.active {
    background: var(--teal);
    border-color: var(--teal);
    color: var(--white);
}

/* ── Invoice table ── */
.table-wrap {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    overflow-x: auto;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.invoice-table thead {
    background: var(--dark);
    color: var(--yellow);
}

.invoice-table thead th {
    padding: 0.75rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 500;
    text-align: left;
    white-space: nowrap;
}

.invoice-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s ease;
}

.invoice-table tbody tr:last-child { border-bottom: none; }
.invoice-table tbody tr:hover { background: #faf9f5; }

.invoice-table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
}

.invoice-table tbody td a {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 500;
}

/* Row status tinting */
.invoice-table tr.status-overdue td:first-child {
    border-left: 3px solid var(--red);
}
.invoice-table tr.status-paid td:first-child {
    border-left: 3px solid #1a7a3c;
}
.invoice-table tr.status-sent td:first-child {
    border-left: 3px solid var(--teal);
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-lg { font-size: 0.75rem; padding: 0.3rem 0.75rem; }

.badge-draft   { background: #f0f0f0; color: var(--muted); }
.badge-sent    { background: #e0f2f7; color: var(--teal-d); }
.badge-paid    { background: #e4f5eb; color: #1a7a3c; }
.badge-overdue { background: #fff0f0; color: #c90001; }

/* ── Currency tag ── */
.currency-tag {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    background: var(--yellow);
    color: var(--dark);
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
}

/* ── Action buttons in table ── */
.actions-cell {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}

.action-link {
    font-size: 1rem;
    text-decoration: none;
    opacity: 0.75;
    transition: opacity 0.15s;
    cursor: pointer;
    line-height: 1;
    padding: 0.2rem;
}
.action-link:hover { opacity: 1; text-decoration: none; }

.action-btn {
    font-size: 1rem;
    background: none;
    border: none;
    padding: 0.2rem;
    cursor: pointer;
    opacity: 0.75;
    line-height: 1;
    transition: opacity 0.15s;
}
.action-btn:hover { opacity: 1; }

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--border);
}
.empty-state p {
    color: var(--muted);
    font-style: italic;
    margin-bottom: 1rem;
}

/* ════════════════════════════════════════
   INVOICE FORM
════════════════════════════════════════ */

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-section {
    background: var(--white);
    border-radius: var(--radius-lg);
    border-top: 3px solid var(--yellow);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.section-title {
    font-size: 0.85rem;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
    margin-bottom: 1.1rem;
    padding-bottom: 0.6rem;
    border-bottom: 2px solid var(--red);
}

/* ── Line items section ── */
.line-items-section {
    margin-bottom: 1.5rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0;
}

.line-items-table-wrap {
    overflow-x: auto;
    border-radius: var(--radius) var(--radius) 0 0;
    border: 1px solid var(--border);
    border-bottom: none;
}

.line-items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.line-items-table thead {
    background: var(--dark);
}

.line-items-table thead th {
    padding: 0.65rem 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--yellow);
    font-weight: 500;
    text-align: left;
    white-space: nowrap;
}

.line-items-table tbody tr {
    border-bottom: 1px solid var(--border);
}
.line-items-table tbody tr:last-child {
    border-bottom: none;
}
.line-items-table tbody tr:hover {
    background: #faf9f5;
}

.line-items-table tbody td {
    padding: 0.5rem 0.5rem;
    vertical-align: middle;
}

/* Line item inputs */
.item-desc,
.item-qty,
.item-rate {
    width: 100%;
    font-family: var(--font-serif);
    font-size: 0.88rem;
    color: var(--dark);
    background: transparent;
    border: 1.5px solid transparent;
    border-radius: var(--radius);
    padding: 0.4rem 0.5rem;
    transition: border-color 0.15s, background 0.15s;
}

.item-qty, .item-rate {
    font-family: var(--font-mono);
    text-align: right;
}

.item-desc:focus,
.item-qty:focus,
.item-rate:focus {
    outline: none;
    border-color: var(--teal);
    background: var(--white);
    box-shadow: 0 0 0 2px rgba(0,121,152,0.10);
}

/* Rate input with currency prefix */
.rate-input-wrap {
    display: flex;
    align-items: center;
    border: 1.5px solid transparent;
    border-radius: var(--radius);
    transition: border-color 0.15s;
    overflow: hidden;
}
.rate-input-wrap:focus-within {
    border-color: var(--teal);
    background: var(--white);
    box-shadow: 0 0 0 2px rgba(0,121,152,0.10);
}

.input-prefix {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--muted);
    padding: 0.4rem 0.3rem 0.4rem 0.5rem;
    flex-shrink: 0;
    background: transparent;
    user-select: none;
}

.rate-input-wrap .item-rate {
    border: none;
    box-shadow: none;
    flex: 1;
    padding-left: 0.15rem;
}
.rate-input-wrap .item-rate:focus {
    border: none;
    box-shadow: none;
    background: transparent;
}

/* Amount display (readonly) */
.amount-display {
    font-family: var(--font-mono);
    font-size: 0.88rem;
    color: var(--dark);
    font-weight: 500;
    text-align: right;
    padding: 0.4rem 0.5rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.05rem;
}

/* Remove button */
.remove-item-btn {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius);
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}
.remove-item-btn:hover {
    color: var(--red);
    background: #fff0f0;
}

/* Col widths */
.col-desc  { width: 48%; }
.col-qty   { width: 12%; }
.col-rate  { width: 18%; }
.col-amount { width: 16%; }
.col-del   { width: 6%; text-align: center; }

/* Totals rows */
.totals-row td {
    padding: 0.5rem 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.88rem;
}

.totals-label {
    text-align: right;
    color: var(--muted);
}

.totals-value {
    text-align: right;
    font-weight: 500;
    color: var(--dark);
    white-space: nowrap;
}

.totals-row--total {
    border-top: 2px solid var(--red);
    background: #faf9f5;
}

.totals-row--total .totals-label {
    font-size: 1rem;
    color: var(--dark);
    font-weight: 600;
}

.totals-row--total .totals-value {
    font-size: 1.1rem;
    color: var(--teal-d);
}

.vat-notice-row td {
    padding: 0.6rem 0.75rem;
    background: #fdfcf7;
}

.vat-notice {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--muted);
    font-style: italic;
}

/* Add line item button */
.btn-add-item {
    border-radius: 0 0 var(--radius) var(--radius);
    width: 100%;
    border-color: var(--border);
    border-top: none;
    padding: 0.6rem;
    background: #faf9f5;
    color: var(--teal);
    font-size: 0.78rem;
}
.btn-add-item:hover {
    background: var(--teal);
    color: var(--white);
    border-color: var(--teal);
}

/* ── Currency toggle ── */
.currency-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.currency-select {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.88rem;
}

.currency-preview {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--yellow);
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius);
    flex-shrink: 0;
    border: 2px solid transparent;
    transition: all 0.15s ease;
}

.currency-symbol-preview {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1rem;
    color: var(--dark);
}

.currency-name-preview {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--dark);
    opacity: 0.75;
}

/* ── Status select in edit header ── */
.status-select-label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.status-select {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    padding: 0.35rem 1.8rem 0.35rem 0.6rem;
}

/* ── Form actions ── */
.form-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 1.5rem 0;
    border-top: 2px solid var(--border);
    margin-top: 0.5rem;
}

/* ════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════ */

@media (max-width: 800px) {
    .form-grid { grid-template-columns: 1fr; }
    .field-row { grid-template-columns: 1fr; }
    .header-inner { padding: 0 1rem; }
    .container { padding: 0 1rem; }
    .site-nav a:not(.btn):not(.nav-logout) { display: none; }
    .summary-grid { grid-template-columns: 1fr 1fr; }
    .heading-actions { gap: 0.5rem; }
}

@media (max-width: 480px) {
    .summary-grid { grid-template-columns: 1fr; }
    .filter-bar { flex-direction: column; align-items: flex-start; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; }
}
