:root {
  --bg: #050816;
  --bg-deep: #02040d;
  --surface: rgba(13, 20, 38, 0.94);
  --surface-alt: rgba(20, 31, 56, 0.94);
  --text: #f8fafc;
  --muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.22);
  --primary: #5865f2;
  --primary-dark: #3946d4;
  --accent: #ff4655;
  --accent-dark: #db3442;
  --cyan: #21d4fd;
  --danger: #ff4655;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.44);
  --glow-blue: 0 0 28px rgba(88, 101, 242, 0.24);
  --glow-red: 0 0 28px rgba(255, 70, 85, 0.20);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(88, 101, 242, 0.34), transparent 30%),
    radial-gradient(circle at 90% 8%, rgba(255, 70, 85, 0.24), transparent 28%),
    linear-gradient(135deg, var(--bg-deep), var(--bg) 46%, #0e172d);
  color: var(--text);
  overflow: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.026) 1px, transparent 1px);
  background-size: 42px 42px;
}
button, input, select, textarea { font: inherit; }
h1, h2, h3, h4, p { margin-top: 0; }

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  padding: 12px clamp(10px, 1.8vw, 22px) 14px;
  position: relative;
}
.app-header {
  min-height: 88px;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(13, 20, 38, 0.90), rgba(8, 12, 24, 0.96));
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.05);
  backdrop-filter: blur(16px);
}
.eyebrow {
  margin: 0 0 3px;
  color: var(--cyan);
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  font-size: 0.66rem;
}
h1 {
  margin-bottom: 4px;
  font-size: clamp(1.45rem, 2.5vw, 2.45rem);
  line-height: 0.9;
  letter-spacing: -0.06em;
  text-transform: uppercase;
  text-shadow: 0 0 30px rgba(88, 101, 242, 0.32);
}
h2 { margin-bottom: 2px; font-size: clamp(1.06rem, 1.7vw, 1.42rem); letter-spacing: -0.03em; }
h3 { margin-bottom: 3px; font-size: 0.98rem; }
h4 { margin-bottom: 3px; }
.subtitle, .section-heading p, .window-titlebar p, .list-toolbar p, .filter-label { color: var(--muted); }
.subtitle { margin: 0; font-size: 0.82rem; }

.window-switcher {
  display: flex;
  gap: 7px;
  padding: 6px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 999px;
  background: rgba(3, 7, 18, 0.68);
  max-width: 100%;
  overflow-x: auto;
}
.window-button, .primary-button, .secondary-button, .danger-outline, .small-button {
  cursor: pointer;
  font-weight: 900;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, border-color 140ms ease;
}
.window-button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 9px 12px;
  color: #cbd5e1;
  background: transparent;
  white-space: nowrap;
}
.window-button.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: var(--glow-blue), var(--glow-red);
}
.header-actions, .form-actions, .card-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.user-select { min-width: 190px; }
.primary-button, .secondary-button, .danger-outline {
  border-radius: 999px;
  padding: 9px 13px;
  border: 0;
}
.primary-button { background: linear-gradient(135deg, var(--primary), #3448ff); color: #fff; box-shadow: var(--glow-blue); }
.primary-button:hover { background: linear-gradient(135deg, var(--primary-dark), #2638cc); transform: translateY(-1px); }
.secondary-button { background: rgba(88, 101, 242, 0.14); color: #eef2ff; border: 1px solid rgba(88, 101, 242, 0.34); }
.secondary-button:hover { background: rgba(88, 101, 242, 0.22); box-shadow: var(--glow-blue); }
.danger-outline { background: rgba(255, 70, 85, 0.10); border: 1px solid rgba(255, 70, 85, 0.44); color: #fecdd3; }
.danger-outline:hover { background: rgba(255, 70, 85, 0.18); box-shadow: var(--glow-red); }

.workspace { min-height: 0; position: relative; }
.window-panel {
  display: none;
  height: 100%;
  min-height: 0;
  padding: 12px;
  background: linear-gradient(145deg, rgba(13, 20, 38, 0.84), rgba(7, 10, 19, 0.95));
  border: 1px solid var(--border);
  border-radius: 26px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.05);
  backdrop-filter: blur(16px);
  overflow: hidden;
}
.window-panel.active { display: grid; grid-template-rows: auto 1fr; gap: 10px; }
.window-titlebar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 0 4px; }
.window-titlebar p { margin-bottom: 0; }

.compact-layout { min-height: 0; display: grid; grid-template-columns: minmax(390px, 0.72fr) 1.28fr; gap: 10px; }
.card {
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  overflow: hidden;
}
.form-card, .list-card, .dashboard-card { padding: 12px; }
.list-card { display: grid; grid-template-rows: auto 1fr auto; gap: 8px; }
.section-heading, .list-toolbar { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
.compact-heading { margin-bottom: 8px; }
.simple-toolbar { margin-bottom: 0; }

.compact-form { display: grid; gap: 7px; }
.grid { display: grid; gap: 8px; }
.two-cols { grid-template-columns: 1fr 1fr; }
label {
  display: grid;
  gap: 4px;
  margin-bottom: 0;
  font-weight: 900;
  color: #dbeafe;
  font-size: 0.76rem;
}
.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(3, 7, 18, 0.54);
}
.check-line input { width: auto; min-height: auto; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(3, 7, 18, 0.76);
  padding: 8px 10px;
  color: var(--text);
  outline: none;
  min-height: 35px;
}
textarea { resize: none; min-height: 52px; }
select option { background: #111827; color: var(--text); }
input::placeholder, textarea::placeholder { color: #64748b; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.18); }
.form-error { min-height: 15px; margin: 0; color: #fecdd3; font-weight: 900; font-size: 0.78rem; }

.filters-box { display: grid; grid-template-columns: minmax(170px, 1.3fr) minmax(125px, 0.7fr); gap: 8px; min-width: min(500px, 100%); padding: 8px; background: linear-gradient(135deg, rgba(88,101,242,0.12), rgba(255,70,85,0.08)); border: 1px solid var(--border); border-radius: 16px; }
.project-filters { min-width: min(560px, 100%); }
.filter-label { font-size: 0.7rem; }
.items-list { min-height: 0; display: grid; align-content: start; gap: 8px; }
.compact-list, .dashboard-list, .history-list { overflow: auto; padding-right: 4px; scrollbar-width: thin; scrollbar-color: rgba(88,101,242,0.72) rgba(15,23,42,0.55); }

.item-card { border: 1px solid var(--border); border-radius: 16px; padding: 9px; background: rgba(7, 10, 19, 0.74); box-shadow: inset 0 1px 0 rgba(255,255,255,0.04); }
.item-card:hover { border-color: rgba(88,101,242,0.48); box-shadow: var(--glow-blue); }
.important-border { border-color: rgba(255, 70, 85, 0.55); box-shadow: var(--glow-red); }
.item-top { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.item-title { margin: 0 0 2px; font-size: 0.96rem; color: #fff; }
.item-subtitle { margin: 0; color: var(--muted); font-size: 0.8rem; }
.badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; background: rgba(255, 70, 85, 0.14); border: 1px solid rgba(255, 70, 85, 0.35); color: #fecdd3; font-weight: 900; white-space: nowrap; height: fit-content; font-size: 0.74rem; }
.badge.teal { background: rgba(33, 212, 253, 0.10); border-color: rgba(33, 212, 253, 0.35); color: #cffafe; }
.item-details { display: flex; flex-wrap: wrap; gap: 7px 14px; color: #cbd5e1; margin: 6px 0; font-size: 0.8rem; }
.item-note { max-height: 48px; overflow: hidden; background: rgba(88, 101, 242, 0.10); border: 1px solid rgba(88, 101, 242, 0.18); border-radius: 12px; padding: 7px; color: #dbeafe; white-space: pre-wrap; font-size: 0.8rem; margin-top: 6px; }
.muted-note { background: rgba(15, 23, 42, 0.45); color: #cbd5e1; }
.card-actions { margin-top: 8px; }
.small-button { border: 1px solid var(--border); border-radius: 999px; background: rgba(15, 23, 42, 0.92); color: var(--text); padding: 6px 10px; font-size: 0.76rem; }
.small-button:hover { border-color: rgba(88, 101, 242, 0.52); box-shadow: var(--glow-blue); }
.small-button.danger { color: #fecdd3; border-color: rgba(255, 70, 85, 0.36); }
.small-button.danger:hover { box-shadow: var(--glow-red); }
.empty-state { text-align: center; border: 1px dashed rgba(148, 163, 184, 0.32); border-radius: 16px; padding: 16px; color: var(--muted); background: rgba(7, 10, 19, 0.42); }
.compact-empty { padding: 12px; margin: 0; font-size: 0.82rem; }
.hidden { display: none !important; }

.dashboard-grid { min-height: 0; display: grid; grid-template-columns: 0.9fr 1.1fr 1fr; grid-template-rows: auto 1fr; gap: 10px; }
.stats-card { grid-column: 1 / 4; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 10px; }
.stat-box { min-height: 76px; border-radius: 18px; border: 1px solid rgba(88,101,242,0.30); background: linear-gradient(135deg, rgba(88,101,242,0.16), rgba(15,23,42,0.62)); padding: 12px; display: flex; flex-direction: column; justify-content: center; }
.stat-box span { font-size: clamp(1.65rem, 2.4vw, 2.35rem); font-weight: 950; line-height: 1; }
.stat-box p { margin: 3px 0 0; color: var(--muted); font-weight: 800; }
.stat-box.red { border-color: rgba(255,70,85,0.38); background: linear-gradient(135deg, rgba(255,70,85,0.16), rgba(15,23,42,0.62)); }
.search-card, .important-card, .history-card { display: grid; grid-template-rows: auto auto 1fr auto; gap: 8px; min-height: 0; }
.search-result { display: grid; gap: 2px; border: 1px solid var(--border); border-radius: 14px; background: rgba(7,10,19,0.7); padding: 9px; }
.search-result span, .history-entry span { color: var(--cyan); text-transform: uppercase; font-size: 0.66rem; letter-spacing: 0.08em; font-weight: 900; }
.search-result strong { color: white; }
.search-result p { margin: 0; color: var(--muted); font-size: 0.78rem; }
.history-card { grid-template-rows: auto 1fr auto; }
.history-entry { border-left: 3px solid var(--primary); padding: 8px 9px; background: rgba(7,10,19,0.62); border-radius: 12px; margin-bottom: 8px; }
.history-entry p { margin: 2px 0 3px; font-size: 0.82rem; }
.history-entry small { color: var(--muted); }

@media (max-width: 1180px) {
  body { overflow: auto; }
  .app-shell { min-height: 100vh; height: auto; }
  .app-header { grid-template-columns: 1fr; align-items: start; }
  .window-switcher { width: fit-content; max-width: 100%; }
  .window-panel { min-height: 760px; }
  .compact-layout, .dashboard-grid { grid-template-columns: 1fr; }
  .stats-card { grid-column: auto; grid-template-columns: repeat(2, 1fr); }
  .list-card { min-height: 360px; }
}
@media (max-width: 680px) {
  .two-cols, .filters-box, .stats-card { grid-template-columns: 1fr; }
  .section-heading, .list-toolbar, .item-top { flex-direction: column; }
  .window-button { padding: 9px 11px; }
  .header-actions { align-items: stretch; }
  .user-select { min-width: 100%; }
}
