:root {
  --bg: #14161a;
  --panel: #1c1f26;
  --panel-2: #23272f;
  --border: #2c313b;
  --text: #e6e8ec;
  --muted: #9aa3b2;
  --accent: #6ea8fe;
  --green: #46c46a;
  --red: #ec5b5b;
  --amber: #e6b04a;
  --gray: #6b7280;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

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

/* --- nav --- */
.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.nav .brand { font-weight: 700; margin-right: 16px; letter-spacing: .3px; }
.nav a.link {
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 500;
}
.nav a.link.active, .nav a.link:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.nav .spacer { flex: 1; }
.nav .authwarn {
  color: #1a1200;
  background: var(--amber);
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
}
.nav form { margin: 0; }
.btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { background: #2b303a; }
.btn.small { padding: 3px 9px; font-size: 13px; }
.btn.danger { color: #fff; background: #7a2b2b; border-color: #944; }
.btn.danger:hover { background: #954; }

.wrap { padding: 18px; max-width: 1200px; margin: 0 auto; }
h1 { font-size: 20px; margin: 4px 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* --- table --- */
.table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: 13px; }
.table tr.row { cursor: pointer; }
.table tr.row:hover td { background: var(--panel-2); }

/* --- badges --- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.type-note { background: #3a3410; color: #f5e960; }
.type-calendar { background: #10303a; color: #6ed0fe; }
.type-task { background: #2a2340; color: #b79cff; }
.type-project { background: #103a24; color: #6ee6a0; }
.type-unknown { background: #333; color: #bbb; }
.type-null { background: #2a2f38; color: var(--muted); }

.state { font-size: 12px; color: var(--muted); }
.icon { font-size: 15px; }
.i-ok { color: var(--green); }
.i-fail { color: var(--red); }
.i-proc { color: var(--amber); }
.i-skip { color: var(--gray); }

/* --- detail / modal --- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: none; align-items: flex-start; justify-content: center; z-index: 50;
  padding: 40px 16px; overflow: auto;
}
.overlay.open { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 760px; padding: 20px; }
.modal h2 { margin: 0 0 6px; font-size: 18px; }
.modal .close { float: right; }
.kv { margin: 12px 0; }
.kv div { display: flex; gap: 10px; padding: 3px 0; }
.kv .k { color: var(--muted); min-width: 130px; }
pre.code {
  background: #0f1114; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  font-size: 13px; line-height: 1.5; max-height: 340px;
}
.section-title { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; margin: 16px 0 6px; }

/* --- notes grid --- */
#notesGrid { display: grid; gap: 10px; padding: 14px; height: calc(100vh - 52px); overflow: hidden; }
#notesGrid.scroll { height: auto; overflow: auto; }
.note-tile {
  border-radius: 12px; padding: 14px; position: relative; color: #1a1a1a;
  display: flex; align-items: center; justify-content: center; text-align: center;
  overflow: hidden; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.note-tile .note-text { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-box-orient: vertical; }
.note-tile .note-date { position: absolute; bottom: 6px; right: 9px; font-size: 10px; opacity: .55; }

/* --- projects --- */
.proj-layout { display: grid; grid-template-columns: 260px 1fr; gap: 16px; }
.proj-list { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.proj-list .item { padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.proj-list .item:hover, .proj-list .item.active { background: var(--panel-2); }
.proj-list .item .count { color: var(--muted); font-size: 12px; }
.proj-files .file { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; background: var(--panel); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.file .fmeta { min-width: 0; }
.file .fmeta .ftitle { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- forms --- */
input, select { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
input:focus, select:focus { outline: 1px solid var(--accent); }
label { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 13px; }

/* --- login --- */
.login-box { max-width: 340px; margin: 12vh auto; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 24px; }
.login-box h1 { text-align: center; }
.login-box input { width: 100%; }
.login-box .btn { width: 100%; margin-top: 16px; background: var(--accent); color: #06122b; border: none; font-weight: 700; padding: 10px; }
.login-err { color: var(--red); font-size: 13px; text-align: center; margin-top: 10px; }

.empty { color: var(--muted); padding: 40px; text-align: center; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--border); padding: 10px 16px; border-radius: 8px; z-index: 80; display: none; }
.toast.show { display: block; }
