:root {
  --bg: #0f1420;
  --panel: #171d2b;
  --panel-2: #1f2738;
  --line: #2a3348;
  --text: #e8edf6;
  --muted: #8b96ad;
  --accent: #4c7dff;
  --accent-2: #6f97ff;
  --green: #2ecc71;
  --yellow: #f1c40f;
  --red: #ff5b5b;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1d2740 0%, #0f1420 60%);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.login-logo {
  width: 54px; height: 54px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #8a5cff);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: #fff;
  margin-bottom: 18px;
}
.login-card h1 { font-size: 22px; margin: 0 0 4px; }
.login-card p { margin: 0 0 22px; }
.login-card label { display: block; font-size: 12px; color: var(--muted); margin: 14px 0 6px; }
.login-card input {
  width: 100%;
  padding: 11px 13px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-error { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 10px; }
.login-hint {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 18px; padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 11px; color: var(--muted);
}
.login-hint span { background: var(--panel-2); padding: 4px 8px; border-radius: 6px; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  flex-shrink: 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 10px 18px; }
.brand i { color: var(--accent); font-size: 20px; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 9px;
  color: var(--muted); text-decoration: none; font-size: 13.5px;
  cursor: pointer; transition: .15s;
}
.nav a i { width: 18px; text-align: center; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--accent); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 24px; border-bottom: 1px solid var(--line);
  background: rgba(15,20,32,.7); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 5;
}
.topbar h2 { font-size: 17px; margin: 0; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-info { font-size: 12.5px; color: var(--muted); }
.burger { display: none; background: none; border: none; color: var(--text); font-size: 18px; cursor: pointer; }

.content { padding: 24px; flex: 1; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
  display: inline-flex; align-items: center; gap: 7px;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: var(--line); color: var(--red); }
.btn-danger:hover { border-color: var(--red); }
.btn-block { width: 100%; justify-content: center; margin-top: 18px; padding: 11px; font-size: 14px; }
.btn-sm { padding: 5px 9px; font-size: 12px; }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 22px; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
}
.card .label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.card .value { font-size: 22px; font-weight: 700; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.value.green { color: var(--green); }
.value.red { color: var(--red); }
.value.yellow { color: var(--yellow); }

.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.section-head h3 { margin: 0; font-size: 16px; flex: 1; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 8px 11px; border-radius: 9px; font-size: 13px; outline: none;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--accent); }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--panel-2); color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
tbody tr:hover { background: rgba(76,125,255,.06); }
tbody tr:last-child td { border-bottom: none; }
td.money, th.money { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 6px; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge.green { background: rgba(46,204,113,.16); color: var(--green); }
.badge.yellow { background: rgba(241,196,15,.16); color: var(--yellow); }
.badge.red { background: rgba(255,91,91,.16); color: var(--red); }
.badge.grey { background: rgba(139,150,173,.16); color: var(--muted); }
.badge.blue { background: rgba(76,125,255,.16); color: var(--accent-2); }

.status-select {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 5px 8px; border-radius: 8px; font-size: 12px;
}

/* ---------- quick links ---------- */
.links-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.link-card {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 22px 14px; border-radius: var(--radius);
  color: #fff; text-decoration: none; text-align: center;
  min-height: 110px; transition: transform .12s;
}
.link-card:hover { transform: translateY(-3px); }
.link-card i { font-size: 26px; }
.link-card span { font-size: 13px; font-weight: 600; }
.link-card .link-actions {
  position: absolute; top: 8px; right: 8px;
  display: none; gap: 4px;
}
.link-card:hover .link-actions { display: flex; }
.link-card .link-actions button {
  background: rgba(0,0,0,.35); border: none; color: #fff;
  width: 26px; height: 26px; border-radius: 7px; cursor: pointer;
}

/* ---------- kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: start; }
.kanban-col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-height: 200px; }
.kanban-col.over { border-color: var(--accent); background: rgba(76,125,255,.06); }
.kanban-col h4 { margin: 0 0 12px; font-size: 13px; display: flex; justify-content: space-between; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.kanban-col h4 .count { background: var(--panel-2); padding: 1px 8px; border-radius: 20px; font-size: 11px; }
.task-card {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; margin-bottom: 10px; cursor: grab;
}
.task-card:active { cursor: grabbing; }
.task-card .t-title { font-weight: 600; margin-bottom: 6px; font-size: 13.5px; }
.task-card .t-meta { font-size: 11.5px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.task-card .t-actions { display: flex; gap: 6px; margin-top: 10px; }
.prio { display: inline-block; padding: 1px 7px; border-radius: 20px; font-size: 10.5px; font-weight: 700; }
.prio.p1 { background: rgba(255,91,91,.2); color: var(--red); }
.prio.p2 { background: rgba(241,196,15,.2); color: var(--yellow); }
.prio.p3 { background: rgba(139,150,173,.2); color: var(--muted); }

/* ---------- timesheet ---------- */
.ts-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.ts-table { border-collapse: collapse; font-size: 12px; width: 100%; }
.ts-table th, .ts-table td { border: 1px solid var(--line); padding: 0; text-align: center; white-space: nowrap; }
.ts-table th { background: var(--panel-2); padding: 8px 6px; color: var(--muted); font-size: 11px; }
.ts-table td:first-child, .ts-table th:first-child {
  position: sticky; left: 0; background: var(--panel); z-index: 2;
  text-align: left; padding: 8px 12px; min-width: 150px; font-weight: 600;
}
.ts-table th:first-child { background: var(--panel-2); }
.ts-cell { width: 100%; height: 34px; border: none; background: transparent; color: var(--text); text-align: center; font-size: 12px; cursor: pointer; }
.ts-cell:focus { background: var(--panel-2); outline: 2px solid var(--accent); }
.ts-weekend { background: rgba(255,91,91,.07); }
.ts-cell[data-code="О"] { color: #8a5cff; }
.ts-cell[data-code="Б"] { color: var(--yellow); }
.ts-cell[data-code="К"] { color: var(--accent-2); }
.ts-cell[data-code="Р"] { color: var(--green); }
.ts-cell[data-code="Н"] { color: var(--red); }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(6,9,16,.7);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  width: 100%; max-width: 520px; max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 24px 70px rgba(0,0,0,.5);
}
.modal-wide { max-width: 1000px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; flex: 1; }
.modal-body { padding: 20px; overflow-y: auto; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); padding: 9px 12px; border-radius: 9px; font-size: 13.5px; outline: none;
  font-family: inherit;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { border-color: var(--accent); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.form-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.viewer-body { padding: 16px 20px 20px; overflow: auto; max-height: 76vh; }
.viewer-body iframe { width: 100%; height: 74vh; border: none; border-radius: 8px; background: #fff; }
.viewer-body img { max-width: 100%; border-radius: 8px; }
.viewer-body pre { white-space: pre-wrap; word-break: break-word; font-size: 12.5px; background: var(--panel-2); padding: 14px; border-radius: 8px; }
.xls-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.xls-tabs button {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 12.5px;
}
.xls-tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.doc-html { background: #fff; color: #111; padding: 24px; border-radius: 8px; font-size: 14px; line-height: 1.6; }
.doc-html table { width: auto; }
.doc-html th, .doc-html td { border: 1px solid #ccc; padding: 6px 10px; color: #111; }
.xls-html { background: #fff; color: #111; border-radius: 8px; overflow: auto; }
.xls-html table { border-collapse: collapse; }
.xls-html td, .xls-html th { border: 1px solid #ddd; padding: 5px 9px; color: #111; font-size: 12.5px; white-space: nowrap; }

/* ---------- misc ---------- */
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs button {
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  padding: 8px 16px; border-radius: 9px; cursor: pointer; font-size: 13px;
}
.tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 12px 20px; border-radius: 10px; z-index: 200; font-size: 13.5px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.toast.error { border-color: var(--red); color: var(--red); }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: .2s; }
  .sidebar.open { transform: translateX(0); }
  .burger { display: block; }
  .kanban { grid-template-columns: 1fr; }
  .form-grid2 { grid-template-columns: 1fr; }
}
.vendor-tabs { display:flex; gap:6px; border-bottom:1px solid rgba(255,255,255,.1); margin-bottom:14px; }
.vendor-tabs button { background:none; border:none; padding:8px 14px; color:inherit; opacity:.6; cursor:pointer; border-bottom:2px solid transparent; }
.vendor-tabs button.active { opacity:1; border-bottom-color:var(--accent,#4c7dff); }
.vendor-card { display:grid; grid-template-columns:1fr 1fr; gap:10px 20px; }
.vendor-card .kv { display:flex; flex-direction:column; gap:2px; }
.vendor-card .kv-l { font-size:11.5px; opacity:.55; text-transform:uppercase; letter-spacing:.03em; }
.vendor-card .kv-v { font-size:14px; }
.file-upload { display:flex; gap:8px; align-items:center; margin-bottom:12px; flex-wrap:wrap; }
.comment-form { display:flex; gap:8px; margin-bottom:12px; align-items:flex-start; }
.comment-form textarea { flex:1; }
.comment { padding:10px 0; border-bottom:1px solid rgba(255,255,255,.08); }
.comment .c-head { font-size:12.5px; margin-bottom:4px; }
.comment .c-text { white-space:normal; }
@media (max-width:700px){ .vendor-card { grid-template-columns:1fr; } }

.trash-note{font-size:12px;color:var(--muted)}
.filters{display:flex;gap:6px;flex-wrap:wrap;align-items:center}
.filters .btn{display:inline-flex;gap:5px;align-items:center}
#trash-search{min-width:240px}
@media(max-width:700px){#trash-search{min-width:0;width:100%}}
