:root {
  --ink: #17263b; --soft: #3c4c61; --muted: #5b6b7e; --paper: #f3f5f8; --surface: #fff;
  --line: #d5dee8; --mist: #e4ecf3; --blue: #2d5b88; --blue-deep: #1f4369; --red: #b23a28; --yellow: #e2a82a;
  --ok-bg: #e5f2ea; --ok: #1d5b36; --err-bg: #fbe9e6;
  --sans: "Segoe UI Variable Text", "Segoe UI", "Avenir Next", "Helvetica Neue", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.55 var(--sans); }
a { color: var(--blue); }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 1.6rem; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: #c4cfdc; padding: 20px 14px; display: flex; flex-direction: column; gap: 20px; }
.sidebar .brand { color: #fff; font-weight: 700; font-size: 1.15rem; letter-spacing: .05em; text-decoration: none; padding: 0 10px; }
.sidebar .brand small { display: block; font-weight: 400; letter-spacing: 0; font-size: .8rem; color: #9fb0c3; }
.sidebar ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sidebar a { display: block; padding: 9px 10px; border-radius: 7px; color: #d7e0ea; text-decoration: none; }
.sidebar a:hover { background: #22354f; color: #fff; }
.sidebar a[aria-current="page"] { background: #2b4363; color: #fff; box-shadow: inset 3px 0 0 var(--yellow); }
.sidebar .group { font-size: .8rem; color: #8ea2b8; padding: 0 10px 4px; }
.sidebar .bottom { margin-top: auto; display: grid; gap: 4px; }
.sidebar form button { width: 100%; text-align: left; background: none; border: 0; color: #d7e0ea; font: inherit; padding: 9px 10px; border-radius: 7px; cursor: pointer; }
.sidebar form button:hover { background: #22354f; color: #fff; }

.main { padding: 28px clamp(16px, 3vw, 40px) 60px; max-width: 1180px; width: 100%; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.head p { margin: 4px 0 0; color: var(--muted); max-width: 60em; }

.btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--blue); background: var(--blue); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--blue-deep); color: #fff; }
.btn-quiet { background: var(--surface); color: var(--blue); border-color: var(--line); }
.btn-quiet:hover { background: var(--mist); color: var(--blue-deep); }
.btn-danger { background: var(--surface); color: var(--red); border-color: #e6c3bd; }
.btn-danger:hover { background: var(--err-bg); color: var(--red); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px; }
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.flash.error { background: var(--err-bg); color: var(--red); }

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input { min-width: 260px; }

table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; background: #f8fafc; }
tr:last-child td { border-bottom: 0; }
td.thumb { width: 64px; }
td.thumb img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; background: var(--mist); }
td.actions { text-align: right; white-space: nowrap; }
.tag { display: inline-block; font-size: .8rem; padding: 2px 8px; border-radius: 999px; background: var(--mist); color: var(--soft); }
.tag.yes { background: var(--ok-bg); color: var(--ok); }
.table-wrap { overflow-x: auto; }

.form { display: grid; gap: 18px; max-width: 760px; }
.form-row { display: grid; gap: 6px; }
.form-row > label, .label { font-weight: 600; }
.help { color: var(--muted); font-size: .88rem; margin: 0; }
.error-text { color: var(--red); font-size: .88rem; font-weight: 600; margin: 0; }
input[type=text], input[type=email], input[type=url], input[type=number], input[type=date], input[type=password], input[type=search], select, textarea {
  font: inherit; color: var(--ink); width: 100%; padding: 9px 12px; min-height: 42px;
  border: 1px solid #b9c6d4; border-radius: 8px; background: #fff;
}
textarea { min-height: 120px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.check input { width: 20px; height: 20px; }
.has-error input, .has-error select, .has-error textarea, .has-error .editor { border-color: var(--red); }
.file-current { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 10px; border: 1px dashed var(--line); border-radius: 8px; }
.file-current img { max-height: 120px; width: auto; border-radius: 6px; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding-top: 6px; }
.form-actions .spacer { flex: 1; }

.editor-wrap { border: 1px solid #b9c6d4; border-radius: 8px; background: #fff; }
.editor-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); background: #f8fafc; border-radius: 8px 8px 0 0; }
.editor-bar button { font: inherit; font-size: .88rem; min-width: 34px; min-height: 32px; padding: 4px 8px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--soft); cursor: pointer; }
.editor-bar button:hover { background: var(--mist); border-color: var(--line); }
.editor { min-height: 260px; padding: 12px 16px; outline: none; line-height: 1.65; }
.editor:focus { box-shadow: inset 0 0 0 2px var(--yellow); border-radius: 0 0 8px 8px; }
.editor h2 { font-size: 1.3rem; } .editor h3 { font-size: 1.1rem; }
.editor blockquote { border-left: 4px solid var(--yellow); margin: 1em 0; padding-left: 14px; font-style: italic; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; text-decoration: none; color: var(--ink); }
.stat:hover { border-color: var(--blue); }
.stat strong { display: block; font-size: 1.7rem; line-height: 1.1; }
.stat span { color: var(--muted); }
.todo { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.todo li { background: #fff8e8; border: 1px solid #f0d9a3; border-radius: 8px; padding: 10px 14px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 400px; padding: 28px; }
.login .bars { display: flex; gap: 4px; margin-bottom: 16px; }
.login .bars span { width: 28px; height: 6px; border-radius: 3px; background: var(--red); }
.login .bars span:nth-child(2) { background: var(--yellow); } .login .bars span:nth-child(3) { background: var(--blue); }

.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; color: var(--muted); }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { padding: 12px; gap: 10px; }
  .sidebar ul { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .sidebar .bottom { margin-top: 0; }
  .toolbar input { min-width: 0; flex: 1; }
  th.hide-sm, td.hide-sm { display: none; }
}
