:root {
  --bg: #f4f6fb;
  --card: #fff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --ok-bg: #ecfdf5;
  --ok-border: #a7f3d0;
  --ok-text: #065f46;
  --err-bg: #fef2f2;
  --err-border: #fecaca;
  --err-text: #991b1b;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }

.topbar { background: #1e293b; color: #fff; padding: 12px 24px; display: flex; align-items: center; gap: 24px; }
.topbar .brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.1rem; }
.topbar nav { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.topbar nav a { color: #cbd5e1; text-decoration: none; }
.topbar nav a:hover { color: #fff; }
.topbar .user { color: #94a3b8; font-size: .9rem; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px; }

h1 { font-size: 1.6rem; margin: 0 0 16px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 18px 0 8px; }

.card { background: var(--card); border-radius: 12px; box-shadow: 0 2px 6px rgba(0,0,0,.04); padding: 20px 24px; margin-bottom: 20px; }

label { display: block; font-size: .9rem; font-weight: 600; margin: 12px 0 6px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 1rem; font-family: inherit;
}
input:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
textarea { resize: vertical; min-height: 60px; }

button, .btn, .btn-primary, .btn-sm, .btn-danger { font-family: inherit; }
button.btn-primary, .btn-primary { background: var(--primary); color: #fff; border: 0; padding: 10px 18px; border-radius: 8px; font-weight: 600; cursor: pointer; font-size: .95rem; text-decoration: none; display: inline-block; }
.btn-primary:hover { background: var(--primary-hover); }
.btn { background: #fff; color: var(--text); border: 1px solid var(--border); padding: 10px 18px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-block; font-weight: 500; }
.btn:hover { background: #f9fafb; }
.btn-sm { background: #fff; color: var(--text); border: 1px solid var(--border); padding: 5px 10px; border-radius: 6px; cursor: pointer; text-decoration: none; font-size: .85rem; }
.btn-sm:hover { background: #f9fafb; }
.btn-danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: var(--danger); color: #fff; }

.row { display: flex; gap: 12px; align-items: center; }
.row.between { justify-content: space-between; }

.grid-3 { display: grid; grid-template-columns: 2fr 1fr 2fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 720px) { .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.back { color: var(--muted); text-decoration: none; font-size: .9rem; }
.back:hover { color: var(--primary); }
.hidden { display: none !important; }

.ok { background: var(--ok-bg); border: 1px solid var(--ok-border); color: var(--ok-text); padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.err { background: var(--err-bg); border: 1px solid var(--err-border); color: var(--err-text); padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.warn { background: var(--warn-bg); border: 1px solid var(--warn-border); color: #92400e; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }

.create-form { background: linear-gradient(135deg, #eef2ff 0%, #fff 100%); }

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.list th { font-size: .8rem; text-transform: uppercase; color: var(--muted); font-weight: 600; }
table.list td.actions { text-align: right; white-space: nowrap; }
table.list td.actions form { display: inline; margin-left: 4px; }

.day-list, .entry-list { list-style: none; padding: 0; margin: 12px 0 0; }
.day-row, .entry-row { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; background: #fafafa; }
.day-row .drag, .entry-row .drag { cursor: grab; color: #9ca3af; user-select: none; font-size: 1.2rem; }
.day-row .info, .entry-row .info { flex: 1; }
.day-row .actions, .entry-row .actions { display: flex; gap: 6px; }
.time-chip { display: inline-block; background: #eef2ff; color: #4338ca; font-size: .8rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; margin-left: 8px; vertical-align: middle; }

.add-day-form { background: #f9fafb; padding: 16px; border-radius: 8px; margin: 12px 0; }

/* Login */
.login-body { background: #1e293b; min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login { background: #fff; padding: 32px; border-radius: 12px; width: 360px; max-width: 90%; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login h1 { font-size: 1.4rem; margin: 0 0 4px; }
.login .sub { color: var(--muted); margin: 0 0 16px; }
.login button { width: 100%; margin-top: 16px; }

/* Rich text editor */
.editor-toolbar { display: flex; gap: 4px; flex-wrap: wrap; background: #f9fafb; border: 1px solid var(--border); border-radius: 8px 8px 0 0; padding: 6px; }
.editor-toolbar button { background: #fff; border: 1px solid var(--border); border-radius: 4px; padding: 4px 10px; cursor: pointer; font-size: .9rem; min-width: 32px; }
.editor-toolbar button:hover { background: #eef2ff; }
.editor-toolbar .sep { width: 1px; background: var(--border); margin: 2px 4px; }
.editor { border: 1px solid var(--border); border-top: 0; border-radius: 0 0 8px 8px; padding: 16px; min-height: 220px; max-height: 600px; overflow-y: auto; background: #fff; }
.editor:focus { outline: none; border-color: var(--primary); }
.editor h2 { font-size: 1.3rem; margin: 16px 0 8px; }
.editor h3 { font-size: 1.1rem; margin: 12px 0 6px; }
.editor p { margin: 8px 0; }
.editor img { max-width: 100%; height: auto; }
.editor a { color: var(--primary); }

/* Files */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-top: 12px; }
.file-card { border: 1px solid var(--border); border-radius: 8px; padding: 8px; background: #fff; display: flex; flex-direction: column; gap: 6px; }
.file-card img { width: 100%; height: 120px; object-fit: cover; border-radius: 4px; display: block; }
.file-card .file-icon { display: block; height: 120px; line-height: 120px; text-align: center; font-size: 3rem; text-decoration: none; background: #f3f4f6; border-radius: 4px; }
.file-card .file-meta { display: flex; flex-direction: column; font-size: .85rem; min-height: 38px; }
.file-card .file-meta a { color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card form { margin: 0; }
.file-card form button { width: 100%; }

hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
