:root {
  --bg: #0a1f45;
  --bg2: #0f2a5c;
  --card: #133570;
  --card2: #1a4189;
  --line: #2a5ab0;
  --text: #eef4ff;
  --muted: #9db4dc;
  --accent: #38d9ff;
  --green: #2ecc71;
  --amber: #f5b301;
  --red: #ff4d5e;
  --radius: 14px;
  font-family: "Segoe UI", system-ui, -apple-system, Tahoma, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); min-height: 100%; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
button, input, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.err { color: var(--red); min-height: 1.2em; }

/* Buttons */
.btn {
  background: var(--card2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; cursor: pointer; font-weight: 600; transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, #2fb9ff, #1677e6); border-color: #5fd0ff; }
.btn.green { background: linear-gradient(180deg, #34d27a, #1f9e57); border-color: #6ff0a6; }
.btn.danger { background: #5a1a28; border-color: #a33a4f; }
.btn.warn { background: #5a4310; border-color: #b8860b; }
.btn.wide { width: 100%; display: block; margin-top: 8px; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.icon-btn { background: none; border: 0; font-size: 20px; cursor: pointer; padding: 6px; }

/* Lock */
.lock { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.lock-box { width: 100%; max-width: 360px; text-align: center; background: var(--bg2); padding: 28px 22px; border-radius: 20px; border: 1px solid var(--line); }
.lock-icon { width: 80px; height: 80px; border-radius: 18px; }
.lock h1 { margin: 10px 0 4px; }
.lock input { width: 100%; margin-top: 10px; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }

/* Header */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 14px; background: rgba(10, 31, 69, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.reactivated {
  direction: ltr; font-size: 18px; font-weight: 800; padding: 10px 18px; border-radius: 12px; cursor: pointer;
  background: linear-gradient(180deg, #34d27a, #1f9e57); border: 1px solid #6ff0a6; color: #fff;
  box-shadow: 0 0 18px rgba(46, 204, 113, .35);
}
.reactivated:active { transform: scale(.96); }
.top-right { display: flex; align-items: center; gap: 6px; }
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.sync-dot.ok { background: var(--green); }
.sync-dot.busy { background: var(--amber); }
.sync-dot.off { background: var(--red); }

/* Tabs */
.tabs { display: flex; gap: 8px; padding: 10px 14px; align-items: center; flex-wrap: wrap; }
.tab { background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; cursor: pointer; font-weight: 700; }
.tab b { background: var(--bg); border-radius: 999px; padding: 1px 8px; margin-inline-start: 4px; font-size: 13px; }
.tab.active { background: var(--accent); color: #06203f; border-color: var(--accent); }
.tab.active b { background: rgba(255,255,255,.5); }
#search { flex: 1; min-width: 140px; padding: 9px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg2); }

.due-banner { margin: 0 14px 6px; padding: 10px 14px; border-radius: 12px; background: rgba(255, 77, 94, .15); border: 1px solid var(--red); font-weight: 700; }

/* List */
.list { padding: 4px 14px 100px; display: flex; flex-direction: column; gap: 10px; max-width: 900px; margin: 0 auto; }
.section-title { margin: 10px 2px 0; color: var(--muted); font-size: 13px; font-weight: 700; }
.item {
  display: grid; grid-template-columns: 78px 1fr auto; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; cursor: pointer;
}
.item:hover { border-color: var(--accent); }
.item.due { border-color: var(--red); box-shadow: 0 0 0 1px var(--red) inset; }
.days { text-align: center; border-radius: 12px; padding: 8px 4px; font-weight: 800; line-height: 1.1; }
.days .n { font-size: 26px; display: block; direction: ltr; }
.days .l { font-size: 11px; opacity: .9; }
.days.g { background: rgba(46, 204, 113, .18); color: #7dffb5; }
.days.a { background: rgba(245, 179, 1, .18); color: #ffd666; }
.days.r { background: rgba(255, 77, 94, .22); color: #ff9aa5; }
.days.s { background: rgba(56, 217, 255, .15); color: var(--accent); }
.days.p { background: rgba(255, 77, 94, .22); color: #ff9aa5; }
.info { min-width: 0; }
.info .name { font-weight: 800; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: right; }
.info .chan { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: right; }
.info .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.info .meta.bad { color: #ff9aa5; }
.actions { display: flex; flex-direction: column; gap: 6px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

.fab {
  position: fixed; bottom: calc(18px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: linear-gradient(180deg, #2fb9ff, #1677e6); border: 1px solid #5fd0ff; border-radius: 999px;
  padding: 13px 24px; font-weight: 800; cursor: pointer; box-shadow: 0 6px 22px rgba(0,0,0,.4); z-index: 6;
}

/* Sheets */
.sheet-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20; display: flex; justify-content: center; align-items: flex-end; }
.sheet {
  width: 100%; max-width: 640px; max-height: 94vh; background: var(--bg2); border-radius: 20px 20px 0 0;
  border: 1px solid var(--line); display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom);
}
@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 20px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 18px; }
.sheet-body { overflow-y: auto; padding: 14px; }
.card-block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.card-block h3 { margin: 0 0 6px; font-size: 15px; }

.field { margin-bottom: 10px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 700; }
.field .wrap { display: flex; gap: 6px; }
.field input, .field textarea {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
}
.field input.ltr { direction: ltr; text-align: left; }
.copy-btn { flex: none; background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; cursor: pointer; }
.copy-btn:active { transform: scale(.94); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > .btn { flex: 1; }
.status-box { border-radius: 12px; padding: 12px; margin-bottom: 12px; text-align: center; font-weight: 700; }
.status-box .big { font-size: 34px; display: block; direction: ltr; }
.problem-note { background: rgba(255,77,94,.15); border: 1px solid var(--red); border-radius: 12px; padding: 10px; margin-bottom: 12px; }
.history { list-style: none; padding: 0; margin: 0; font-size: 13px; color: var(--muted); }
.history li { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.file-btn { text-align: center; }
.file-btn input { display: none; }

.dialog { width: calc(100% - 30px); max-width: 420px; margin: auto; background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.dialog h3 { margin: 0 0 10px; }
.dialog textarea { width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); margin-bottom: 10px; }

.toast {
  position: fixed; bottom: calc(80px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: #06152f; border: 1px solid var(--accent); padding: 10px 16px; border-radius: 12px; z-index: 50;
  display: flex; gap: 12px; align-items: center; font-weight: 700; box-shadow: 0 6px 20px rgba(0,0,0,.5); max-width: 92vw;
}
.toast button { background: var(--accent); color: #06203f; border: 0; border-radius: 8px; padding: 5px 10px; font-weight: 800; cursor: pointer; }

@media (max-width: 480px) {
  .item { grid-template-columns: 64px 1fr; }
  .actions { grid-column: 1 / -1; flex-direction: row; }
  .actions .btn { flex: 1; }
  .days .n { font-size: 22px; }
  .reactivated { font-size: 16px; padding: 9px 14px; }
}
