:root {
  --teal-bg: #0d2b30;
  --teal-panel: #133b42;
  --teal-panel-light: #1a4a53;
  --brand-red: #d10a0a;
  --brand-red-light: #ff3b3b;
  --text-light: #eaf4f4;
  --text-muted: #9fc2c2;
  --border: #26555c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--teal-bg);
  color: var(--text-light);
  min-height: 100vh;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  row-gap: 8px;
  align-items: center;
  gap: 14px;
  padding: 14px 24px;
  background: var(--teal-panel);
  border-bottom: 2px solid var(--brand-red);
}
.topbar img { height: 40px; }
.topbar h1 {
  font-size: 20px;
  margin: 0;
  letter-spacing: 0.5px;
}
.topbar .spacer { flex: 1; }

@media (max-width: 640px) {
  .topbar {
    padding: 12px 14px;
  }
  .topbar img { height: 30px; }
  .topbar h1 { font-size: 16px; }
  .topbar .spacer { display: none; }
  .topbar a, .topbar span {
    margin-left: 0;
    font-size: 13px;
  }
  .topbar > a, .topbar > span {
    flex: 0 0 auto;
  }
}
.topbar a, .topbar span {
  color: var(--text-light);
  text-decoration: none;
  font-size: 14px;
  margin-left: 16px;
}
.topbar a:hover { color: var(--brand-red-light); }

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

.auth-wrap {
  max-width: 380px;
  margin: 80px auto;
  background: var(--teal-panel);
  padding: 32px;
  border-radius: 12px;
  border-top: 4px solid var(--brand-red);
  text-align: center;
}
.auth-wrap img { height: 70px; margin-bottom: 16px; }
.auth-wrap h2 { margin-top: 0; }

input, select, textarea, button {
  font-family: inherit;
  font-size: 14px;
}
input, select, textarea {
  width: 100%;
  padding: 9px 10px;
  margin-bottom: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--teal-bg);
  color: var(--text-light);
}
label { font-size: 13px; color: var(--text-muted); display: block; margin-bottom: 4px; }

button, .btn {
  background: var(--brand-red);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  display: inline-block;
  text-decoration: none;
}
button:hover, .btn:hover { background: var(--brand-red-light); }
.btn-secondary {
  background: var(--teal-panel-light);
}
.btn-secondary:hover { background: var(--border); }

.error { color: #ff8080; margin-bottom: 12px; font-size: 14px; }

.panel {
  background: var(--teal-panel);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.summary-card {
  background: var(--teal-panel);
  border-radius: 10px;
  padding: 16px 18px;
  border-left: 4px solid var(--brand-red);
}
.summary-card .label { font-size: 13px; color: var(--text-muted); }
.summary-card .value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.summary-card.income { border-left-color: #2fbf71; }
.summary-card.balance-pos { border-left-color: #2fbf71; }
.summary-card.balance-neg { border-left-color: var(--brand-red); }

.type-toggle { display: flex; gap: 10px; margin-bottom: 14px; }
.type-toggle label {
  flex: 1;
  text-align: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
}
.type-toggle input { display: none; }
.type-toggle input:checked + span { color: var(--brand-red-light); font-weight: 700; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}
.form-grid .full { grid-column: 1 / -1; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
th { color: var(--text-muted); font-weight: 600; }
tr:hover td { background: rgba(255,255,255,0.03); }
.tag-expense { color: var(--brand-red-light); font-weight: 600; }
.tag-income { color: #2fbf71; font-weight: 600; }

.filters { margin-bottom: 14px; }
.filters a {
  color: var(--text-muted);
  text-decoration: none;
  margin-right: 16px;
  padding-bottom: 4px;
}
.filters a.active { color: var(--text-light); border-bottom: 2px solid var(--brand-red); }

.table-scroll { overflow-x: auto; }

.directory-col { display: inline-block; width: 32%; vertical-align: top; margin-right: 1%; }
.directory-list { max-height: 320px; overflow-y: auto; margin-bottom: 10px; }
.directory-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.directory-item form { width: auto; margin: 0; }
.directory-item button {
  padding: 3px 8px;
  font-size: 12px;
}

.del-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 3px 8px;
  font-size: 12px;
}
.del-btn:hover { background: var(--brand-red); color: white; border-color: var(--brand-red); }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .directory-col { width: 100%; margin-right: 0; }
}
