:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e2e4e9;
  --text: #1c1f26;
  --text-muted: #6b7280;
  --accent: #3b6ef5;
  --accent-hover: #2f5adf;
  --danger: #e0503f;
  --danger-bg: #fdecea;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

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

button {
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 6px 11px;
  transition: background .15s, border-color .15s;
}
button:hover { background: #f0f1f4; }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover { background: var(--accent-hover); }

button.danger {
  color: var(--danger);
}
button.danger:hover { background: var(--danger-bg); }

input, select, textarea {
  font-family: inherit;
  font-size: 12.5px;
  padding: 6px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

label {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 3px;
  margin-top: 9px;
}
label:first-child { margin-top: 0; }

/* ---------- Layout ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  font-weight: 700;
  font-size: 14px;
}

.nav {
  display: flex;
  gap: 4px;
}
.nav a {
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
}
.nav a.active {
  color: var(--text);
  background: var(--bg);
}

main {
  padding: 14px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ---------- Badge (напоминание о подписках) ---------- */
.reminder-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fff4e5;
  border: 1px solid #f5c98a;
  color: #7a4d00;
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 12.5px;
}
.reminder-badge button.close {
  border: none;
  background: transparent;
  color: #7a4d00;
  font-size: 16px;
  padding: 0 4px;
}

/* ---------- Kanban ---------- */
.board {
  display: grid;
  grid-template-columns: repeat(6, minmax(180px, 1fr));
  gap: 10px;
  overflow-x: auto;
}

.column {
  background: transparent;
  min-width: 180px;
}

.column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 3px 8px;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .02em;
}

.column-count {
  background: var(--bg);
  border-radius: 999px;
  padding: 1px 7px;
  font-weight: 600;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 32px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  box-shadow: var(--shadow);
  cursor: grab;
}
.card:active { cursor: grabbing; }
.card.dragging { opacity: .4; }

.card-name {
  font-weight: 600;
  margin-bottom: 2px;
  font-size: 12.5px;
}
.card-niche {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
}
.card-meta a { color: var(--accent); }

.column.drag-over .card-list {
  outline: 2px dashed var(--accent);
  outline-offset: 4px;
  border-radius: var(--radius);
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.toolbar input[type="search"] { max-width: 240px; }
.toolbar select { width: auto; max-width: 160px; }
.toolbar .primary { margin-left: auto; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 28, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 100;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border-radius: 12px;
  padding: 16px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.modal h2 {
  margin: 0 0 4px;
  font-size: 15px;
}
.modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 16px;
}
.modal-actions .right { display: flex; gap: 8px; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 26px;
  width: 100%;
  max-width: 300px;
  box-shadow: var(--shadow);
}
.login-box h1 {
  font-size: 16px;
  margin: 0 0 16px;
  text-align: center;
}
.login-error {
  color: var(--danger);
  font-size: 11.5px;
  margin-top: 8px;
  min-height: 14px;
}

/* ---------- Subscriptions ---------- */
.sub-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sub-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}
.sub-row.due-soon { border-color: #f0b35c; background: #fffaf0; }
.sub-row.overdue { border-color: var(--danger); background: var(--danger-bg); }
.sub-name { font-weight: 600; min-width: 140px; }
.sub-date { color: var(--text-muted); font-size: 11.5px; min-width: 110px; }
.sub-amount { font-weight: 600; min-width: 80px; }
.sub-comment { color: var(--text-muted); font-size: 11.5px; flex: 1; }
.sub-actions { display: flex; gap: 6px; margin-left: auto; }

.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 32px 0;
  font-size: 12.5px;
}

@media (max-width: 900px) {
  .board { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: stretch; gap: 8px; }
  .sub-row { flex-wrap: wrap; }
}
