:root {
  --brand: #A3292A;
  --brand-dark: #7d1f20;
  --brand-tint: #fbf1f1;
  --text: #1f2328;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f7f7f8;
  --white: #ffffff;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand {
  font-weight: 700;
  font-size: 18px;
  color: var(--brand);
  text-decoration: none;
}
.nav { display: flex; gap: 18px; flex: 1; flex-wrap: wrap; }
.nav a { color: var(--text); font-size: 14px; font-weight: 500; }
.nav a:hover { color: var(--brand); text-decoration: none; }
.user-menu { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.user-name { color: var(--muted); }
.logout { color: var(--brand); font-weight: 500; }

.content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 24px;
}

h1 { font-size: 24px; margin: 0 0 20px; }
h2 { font-size: 18px; margin: 0 0 14px; }

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

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: 10px;
  padding: 16px 18px;
}
.stat-card .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.stat-card .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat-card.negative { border-left-color: var(--danger); }
.stat-card.positive { border-left-color: var(--success); }

table { width: 100%; border-collapse: collapse; background: var(--white); }
table th, table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
table th { background: var(--brand-tint); color: var(--brand-dark); font-weight: 600; font-size: 13px; }
table tr:hover td { background: #fafafa; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.table-wrap table { border: none; border-radius: 0; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}

.btn {
  display: inline-block;
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn-secondary { background: var(--white); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f2f2f2; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-danger { background: var(--danger); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], input[type=file], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
textarea { resize: vertical; min-height: 90px; }
.field { margin-bottom: 16px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs a { padding: 10px 16px; font-size: 14px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; font-size: 14px; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
}
.login-box {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.login-box h1 { color: var(--brand); font-size: 22px; text-align: center; margin-bottom: 24px; }

.muted { color: var(--muted); font-size: 13px; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.doc-list { list-style: none; padding: 0; margin: 0; }
.doc-list li { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.note-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.note-item:last-child { border-bottom: none; }
.note-meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
