:root {
  --green: #217346;          /* Excel green */
  --green-dark: #1a5c38;
  --line: #d0d7de;
  --head-bg: #f3f4f6;
  --sel: #e8f2ec;
  --zebra: #fafbfc;
  --text: #1f2328;
  --muted: #6b7280;
  --danger: #c23b3b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Segoe UI", Arial, "Helvetica Neue", sans-serif;
  color: var(--text);
  background: #eef0f2;
}

body { display: flex; flex-direction: column; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--green);
  color: #fff;
  padding: 10px 16px;
}
.topbar .brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.brand-logo { height: 38px; width: auto; border-radius: 8px; background: #fff; padding: 2px; }
.topbar .spacer { flex: 1; }
.topbar .user { opacity: .9; font-size: 14px; }
.btn-link {
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  padding: 4px 10px;
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 6px;
}
.btn-link:hover { background: rgba(255,255,255,.15); }

/* Tabs (sheet selector) */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 10px 0;
  background: var(--green-dark);
}
.tab {
  border: none;
  background: #cfe3d8;
  color: #12351f;
  padding: 7px 14px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.tab:hover { background: #dcefe4; }
.tab.active { background: #fff; color: var(--green-dark); }

/* Sheet area */
.sheet-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  min-height: 0;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}
.toolbar .spacer { flex: 1; }
.btn {
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.btn:hover { background: var(--green-dark); }
.status { font-size: 13px; color: var(--muted); min-width: 90px; }
.status.saved { color: var(--green); }
.status.error { color: var(--danger); }
.search {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  min-width: 200px;
}

/* Grid */
.grid-wrap { flex: 1; overflow: auto; min-height: 0; }
.grid {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}
.grid thead th {
  position: sticky;
  top: 0;
  background: var(--head-bg);
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: right;
  font-weight: 700;
  z-index: 2;
  white-space: nowrap;
}
.grid thead th.rownum, .grid tbody td.rownum {
  width: 42px;
  text-align: center;
  color: var(--muted);
  background: var(--head-bg);
  position: sticky;
  right: 0;
  z-index: 1;
}
.grid tbody td {
  border: 1px solid var(--line);
  padding: 0;
  vertical-align: middle;
}
.grid tbody tr:nth-child(even) td { background: var(--zebra); }
.grid tbody tr:hover td { background: var(--sel); }

/* Cell inputs — look like plain cells until focused */
.cell-input, .cell-select, .cell-text {
  width: 100%;
  border: none;
  background: transparent;
  padding: 7px 9px;
  font: inherit;
  color: inherit;
  text-align: right;
}
.cell-input:focus, .cell-select:focus, .cell-text:focus {
  outline: 2px solid var(--green);
  outline-offset: -2px;
  background: #fff;
}
.cell-text { resize: vertical; min-height: 32px; line-height: 1.3; }
.cell-num { text-align: left; direction: ltr; }
td.readonly { background: #f6f8fa !important; color: var(--muted); }
td.readonly .cell-input { color: var(--muted); }

/* Checkbox cell — keep as a real table cell (never display:flex on a td,
   that removes it from the column model and misaligns the grid). */
.cell-check { text-align: center; padding: 6px; }
.cell-check input { width: 18px; height: 18px; accent-color: var(--green); cursor: pointer; }

/* Delete button */
.del-btn {
  border: none;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font-size: 15px;
  padding: 6px 8px;
}
.del-btn:hover { color: #8f2020; }
td.actions { width: 44px; text-align: center; }

.empty { padding: 24px; color: var(--muted); text-align: center; }

/* Kindergarten switcher */
.kg-switch { display: flex; align-items: center; gap: 6px; }
.kg-switch label { font-size: 14px; opacity: .9; }
.kg-switch select {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.5);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* Empty / no-access state */
.empty-state { padding: 60px 24px; text-align: center; color: var(--muted); }
.empty-state h2 { color: var(--text); font-weight: 700; }
.empty-state a { color: var(--green); font-weight: 600; text-decoration: none; }
.empty-state a:hover { text-decoration: underline; }

/* Login page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
}
.login-card {
  background: #fff;
  padding: 32px 28px;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  width: 320px;
  display: flex;
  flex-direction: column;
}
.login-logo { display: block; width: 160px; max-width: 70%; height: auto; margin: 0 auto 12px; border-radius: 12px; }
.login-brand { font-size: 22px; font-weight: 800; color: var(--green-dark); text-align: center; }
.login-sub { text-align: center; color: var(--muted); margin-bottom: 18px; }
.login-card label { font-size: 13px; font-weight: 600; margin: 10px 0 4px; }
.login-card input {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 14px;
}
.login-card input:focus { outline: 2px solid var(--green); outline-offset: -1px; }
.login-btn { margin-top: 18px; padding: 10px; font-size: 15px; }
.login-error {
  background: #fdecec;
  color: var(--danger);
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13px;
  margin-bottom: 6px;
  text-align: center;
}
