:root {
  /* Inspired by the old React/MUI dark theme (green accents) */
  --max-width: 1120px;
  --radius: 10px;
  --radius-sm: 8px;

  --bg: #121212;
  --paper: #1e1e1e;
  --text: #ffffff;
  --text-secondary: #b0b0b0;

  --primary: #4caf50;
  --secondary: #81c784;

  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.18);
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.35);

  --focus: 0 0 0 3px rgba(76, 175, 80, 0.35);
}

/* --------------------------------------------------------------------- */

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95em;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1rem 0.3rem;
  border-radius: 8px;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.9rem 1rem;
}

/* --------------------------------------------------------------------- */
/* Top bar / navigation (MUI-ish) */

.topbar {
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.nav-wrap {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
}

.nav-toggle {
  display: none;
}

.nav-toggle-btn {
  display: none;
  user-select: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  line-height: 1;
}

.brand {
  font-weight: 800;
  letter-spacing: 0.2px;
  font-size: 1.1rem;
  color: var(--text);
}

.brand a {
  color: inherit;
  text-decoration: none;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.35rem;
  align-items: center;
}

.nav a {
  color: var(--text-secondary);
  padding: 0.55rem 0.55rem;
  border-bottom: 2px solid transparent;
  border-radius: 8px;
  text-decoration: none;
}

.nav a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  text-decoration: none;
}

.nav a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

@media (max-width: 760px) {
  .nav-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .nav-wrap {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding-top: 0.25rem;
  }

  /* checkbox hack: show menu */
  .nav-toggle:checked ~ .nav-wrap {
    display: flex;
  }

  .nav {
    flex-direction: column;
    align-items: stretch;
  }

  .nav a {
    border-bottom: none;
    border-left: 4px solid transparent;
    border-radius: 10px;
  }

  .nav a.active {
    border-left-color: var(--primary);
    background: rgba(76, 175, 80, 0.08);
  }

  .user-actions {
    justify-content: space-between;
  }
}

.muted {
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------- */
/* Typography */

h1, h2, h3 {
  margin: 0 0 0.75rem;
}

h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
}

h2 {
  font-size: 1.25rem;
  font-weight: 750;
}

h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

p {
  margin: 0.5rem 0;
}

/* --------------------------------------------------------------------- */
/* Cards */

.card {
  padding: 0.9rem 1rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02);
  margin-bottom: 1rem;
}

/* --------------------------------------------------------------------- */
/* Buttons */

.btn {
  display: inline-block;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  background: rgba(255, 255, 255, 0.02);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.06);
  text-decoration: none;
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: rgba(0, 0, 0, 0.87);
  font-weight: 700;
}

.btn.primary:hover {
  filter: brightness(1.05);
}

.btn:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
  box-shadow: var(--focus);
}

.btn.small {
  padding: 0.28rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
}

.btn[disabled],
button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --------------------------------------------------------------------- */
/* Forms */

.form {
  max-width: 560px;
}

.form-row {
  margin-bottom: 0.85rem;
}

label {
  display: block;
  font-weight: 650;
  margin-bottom: 0.35rem;
  color: var(--text-secondary);
}

input,
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  box-sizing: border-box;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  padding: 0;
  background: transparent;
  border: none;
}

input::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

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

.form-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

.checkbox-inline {
  display: inline-flex;
  gap: 0.55rem;
  align-items: center;
  font-weight: 650;
}

.checkbox-inline input {
  width: auto;
  accent-color: var(--primary);
}

/* Filters row (invoice list) */
.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: flex-end;
}

.filters-row .field {
  flex: 1 1 200px;
  min-width: 180px;
}

.filters-row .field.checkbox {
  flex: 0 0 auto;
  min-width: 180px;
}

.filters-row .field.actions {
  flex: 0 0 auto;
}

/* --------------------------------------------------------------------- */
/* Tables */

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.table th,
.table td {
  padding: 0.6rem 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
  vertical-align: top;
}

.table th {
  font-weight: 700;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.02);
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

/* --------------------------------------------------------------------- */
/* Badges / notices */

.badge {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 0.85em;
  margin-left: 0.35rem;
  color: var(--text-secondary);
}

.badge.overdue {
  border-color: rgba(244, 67, 54, 0.6);
  color: #ef9a9a;
}

.row-overdue td {
  background: rgba(244, 67, 54, 0.08);
}

.notice {
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper);
}

.notice.success {
  border-left-color: var(--primary);
}

.notice.error {
  border-left-color: rgba(244, 67, 54, 0.8);
}

/* --------------------------------------------------------------------- */
/* Print/PDF safety: keep invoices readable */

@media print {
  body {
    background: #fff !important;
    color: #111 !important;
  }

  a { color: #111 !important; text-decoration: none !important; }

  .card {
    background: #fff !important;
    border-color: rgba(0, 0, 0, 0.15) !important;
    box-shadow: none !important;
  }

  .table {
    background: #fff !important;
    border-color: rgba(0, 0, 0, 0.15) !important;
  }

  .table th,
  .table td {
    border-bottom-color: rgba(0, 0, 0, 0.12) !important;
    color: #111 !important;
  }

  .table th {
    background: #f6f6f6 !important;
  }
}
