:root {
  --bg: #0b0b0d;
  --surface: #17171a;
  --surface-2: #202023;
  --border: #2c2c30;
  --text: #f2f0f0;
  --text-muted: #9a9a9e;
  --red: #e2222f;
  --red-hover: #ff2e3d;
  --red-dim: rgba(226, 34, 47, 0.14);
  --green: #34c266;
  --amber: #e0a53a;
  --gray: #6f6f74;
}

* { box-sizing: border-box; }

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

.hidden { display: none !important; }

.state-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
}

#main.hidden { display: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  max-width: calc(100% - 32px);
  background: var(--surface-2);
  border: 1px solid var(--red);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1000;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #131315 0%, var(--bg) 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px var(--red-dim);
}

.brand-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-muted);
}

.icon-toolbar {
  display: flex;
  gap: 6px;
}

.icon-tab-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.icon-tab-btn svg { width: 18px; height: 18px; }

.icon-tab-btn.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.profile-strip {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--red);
}

.header-name { font-weight: 700; font-size: 15px; }
.header-position { color: var(--text-muted); font-size: 12px; margin-top: 1px; }

.tab-content {
  padding: 4px 16px 28px;
  animation: fade-in 0.18s ease;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin: 4px 2px 12px;
}

.section-subtitle {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin: 20px 2px 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: 14px;
  padding: 16px;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

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

.card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.field { margin-bottom: 14px; }
.field:last-of-type { margin-bottom: 16px; }
.field .label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.field span:not(.label) { font-size: 15px; font-weight: 500; }

input, select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 15px;
  margin-bottom: 8px;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%239a9a9e'><path d='M5.5 7.5l4.5 5 4.5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 34px;
}

select option {
  background: var(--surface-2);
  color: var(--text);
}

input::placeholder { color: var(--gray); }

input:focus, select:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-dim);
}

.btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 10px;
  background: var(--red);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn:hover { background: var(--red-hover); }
.btn:active { transform: scale(0.98); }

.list { display: flex; flex-direction: column; gap: 10px; }

.list-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: 12px;
  padding: 14px 16px;
}

.list-item-title { font-weight: 700; margin-bottom: 4px; font-size: 15px; }
.list-item-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }

.edit-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.edit-form input { margin-bottom: 8px; }

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.status-planned, .status-new { background: var(--surface-2); color: var(--text-muted); }
.status-completed, .status-done { background: rgba(52, 194, 102, 0.14); color: var(--green); }
.status-cancelled { background: var(--red-dim); color: var(--red-hover); }
.status-in_progress { background: rgba(224, 165, 58, 0.14); color: var(--amber); }

.list-item-actions { display: flex; gap: 8px; margin-top: 10px; }

.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.btn-sm:hover { border-color: var(--red); color: var(--red-hover); }

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

.admin-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.filters-sidebar {
  flex: 0 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  align-self: flex-start;
}

.filters-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.filters-sidebar-header .icon-btn {
  font-size: 17px;
  color: var(--text-muted);
}

.admin-main {
  flex: 1 1 auto;
  min-width: 0;
}

.admin-main-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.admin-main-toolbar .btn {
  width: auto;
  padding: 11px 18px;
}

.bulk-actions-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--red-dim);
  border: 1px solid var(--red);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text);
}

.bulk-actions-bar .btn-sm {
  border-color: var(--red);
  color: var(--red-hover);
}

.data-table input[type="checkbox"] {
  appearance: auto;
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: none;
  margin: 0;
  cursor: pointer;
}

@media (min-width: 760px) {
  .admin-layout {
    flex-direction: row;
    align-items: flex-start;
  }

  .filters-sidebar {
    width: 240px;
  }
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
  table-layout: fixed;
}

.data-table th, .data-table td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.data-table th {
  position: relative;
}

.col-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}

.col-resizer:hover, .col-resizer.resizing {
  background: var(--red);
  opacity: 0.6;
}

.data-table thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }

.data-table .edit-row td {
  background: var(--surface-2);
  white-space: normal;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  padding: 4px 6px;
  border-radius: 6px;
}

.icon-btn:hover { color: var(--red-hover); }

.icon-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.icon-btn:disabled:hover { color: var(--text-muted); }

.data-table input[type="checkbox"]:disabled { opacity: 0.3; cursor: not-allowed; }

.data-table thead th[draggable="true"] { cursor: grab; }
.data-table thead th[draggable="true"]:active { cursor: grabbing; }
