:root {
  --color-light: #A8B59C;
  --color-mid:   #849655;
  --color-dark:  #3E5B3A;
  --color-bg:    #F5F7F3;
  --color-white: #FFFFFF;
  --color-text:  #26331F;
  --color-danger:#C0392B;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}
a { color: var(--color-dark); }

.topbar {
  background: var(--color-dark);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 500;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; }
.topbar .brand .brand-logo { height: 30px; width: 30px; object-fit: contain; flex-shrink: 0; }
.topbar-right { display: flex; align-items: center; }

.layout { display: flex; min-height: calc(100vh - 60px); }

.sidebar {
  width: 230px;
  background: var(--color-white);
  border-right: 1px solid #e2e6de;
  padding: 20px 0;
}
.sidebar a {
  display: block;
  padding: 10px 22px;
  color: var(--color-text);
  text-decoration: none;
  border-left: 3px solid transparent;
}
.sidebar a:hover, .sidebar a.active {
  background: var(--color-light);
  border-left-color: var(--color-dark);
  color: var(--color-dark);
  font-weight: 600;
}

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

.card {
  background: var(--color-white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 2px 6px rgba(62,91,58,0.10), 0 1px 2px rgba(0,0,0,0.04);
  margin-bottom: 20px;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.card:hover { box-shadow: 0 6px 16px rgba(62,91,58,0.14), 0 2px 4px rgba(0,0,0,0.06); }

.btn {
  display: inline-block;
  background: var(--color-mid);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  font-size: 0.95rem;
}
.btn:hover { background: var(--color-dark); }
.btn-outline { background: transparent; border: 1px solid var(--color-dark); color: var(--color-dark); }
.btn-outline:hover { background: var(--color-dark); color: #fff; }
.btn-danger { background: var(--color-danger); }
.btn-danger:hover { background: #96271c; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #e5e9e1; }
th { background: var(--color-light); color: var(--color-dark); }

.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; }
.alert-error   { background: #fbe9e7; color: #9b2c1f; border: 1px solid #f1c4bd; }
.alert-success { background: #e8f3e3; color: var(--color-dark); border: 1px solid var(--color-light); }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-light), var(--color-dark));
}
.login-box {
  background: #fff;
  padding: 36px 32px;
  border-radius: var(--radius);
  width: 100%;
  max-width: 380px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.login-box h1 { color: var(--color-dark); font-size: 1.3rem; margin-bottom: 4px; }
.login-box .login-logo { max-width: 220px; width: 100%; height: auto; display: block; margin: 0 auto 10px; }
.login-box .sub { color: #666; font-size: 0.85rem; margin-bottom: 20px; }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=time], input[type=month], input[type=datetime-local],
select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccd3c5;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 0.95rem;
  box-sizing: border-box;
}
label { display: block; font-weight: 600; font-size: 0.85rem; color: var(--color-dark); margin-bottom: 4px; }

/* Native date/time pickers - theme to match instead of stock browser look */
input[type=date], input[type=time], input[type=month], input[type=datetime-local] {
  color-scheme: light;
  accent-color: var(--color-dark);
  background: #fbfdf9;
  font-family: inherit;
  cursor: pointer;
}
input[type=date]:focus, input[type=time]:focus, input[type=month]:focus, input[type=datetime-local]:focus {
  outline: none;
  border-color: var(--color-mid);
  box-shadow: 0 0 0 3px rgba(132,150,85,0.2);
}
input[type=date]::-webkit-calendar-picker-indicator,
input[type=time]::-webkit-calendar-picker-indicator,
input[type=month]::-webkit-calendar-picker-indicator,
input[type=datetime-local]::-webkit-calendar-picker-indicator {
  filter: invert(28%) sepia(19%) saturate(1189%) hue-rotate(60deg) brightness(94%) contrast(90%);
  cursor: pointer;
}

.site-footer {
  text-align: center;
  padding: 16px;
  font-size: 0.82rem;
  color: #667a5c;
  border-top: 1px solid #e2e6de;
  background: #fff;
}
.site-footer a { color: var(--color-dark); font-weight: 600; text-decoration: none; }

.badge { display:inline-block; padding: 2px 10px; border-radius: 20px; font-size: 0.78rem; }
.badge-active { background:#e8f3e3; color: var(--color-dark); }
.badge-inactive { background:#f6dede; color:#9b2c1f; }
.badge-warn { background:#fdf3d8; color:#8a6d1a; }
.badge-neutral { background:#eef0ec; color:#767b70; }

.credential-box {
  background: #fbfdf9;
  border: 1px dashed var(--color-mid);
  padding: 14px;
  border-radius: var(--radius);
  font-family: monospace;
}

/* Password show/hide eye */
.pw-wrap {
  display: flex;
  align-items: center;
  border: 1px solid #ccd3c5;
  border-radius: 8px;
  margin-bottom: 14px;
  background: #fff;
  overflow: hidden;
}
.pw-wrap input {
  flex: 1;
  border: none !important;
  margin-bottom: 0 !important;
  border-radius: 0;
  padding-right: 8px;
}
.pw-wrap input:focus { outline: none; box-shadow: none; }
.pw-eye {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 12px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7a8a70;
}
.pw-eye:hover { color: var(--color-dark); }
.pw-eye svg { width: 20px; height: 20px; display: block; }
.pw-eye .icon-eye-off { display: none; }
.pw-wrap.revealed .icon-eye { display: none; }
.pw-wrap.revealed .icon-eye-off { display: block; }

/* Mobile hamburger (hidden on desktop) */
.hamburger {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  margin-right: 10px;
}

/* Bell notification icon */
.bell-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  color: #fff;
  margin-right: 14px;
  text-decoration: none;
  vertical-align: middle;
}
.bell-btn svg { width: 20px; height: 20px; }
.bell-badge {
  position: absolute;
  top: -6px;
  right: -8px;
  background: var(--color-danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

.site-footer a { transition: color 0.15s ease; }
.site-footer a:hover { color: var(--color-mid); text-decoration: underline; }

/* Stat box grid (dashboard) */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-box {
  background: linear-gradient(155deg, #ffffff 0%, #fbfdf9 100%);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: 0 2px 6px rgba(62,91,58,0.10), 0 1px 2px rgba(0,0,0,0.05);
  border-left: 4px solid var(--color-mid);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.stat-box:hover { box-shadow: 0 8px 18px rgba(62,91,58,0.16), 0 2px 4px rgba(0,0,0,0.06); transform: translateY(-2px); }
.stat-box.warn { border-left-color: var(--color-danger); }
.stat-box.ok { border-left-color: var(--color-dark); }
.stat-box .stat-icon {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--color-light);
  color: var(--color-dark);
  display: flex; align-items: center; justify-content: center;
}
.stat-box.warn .stat-icon { background: #fbe4e1; color: var(--color-danger); }
.stat-box.ok .stat-icon { background: #e3ecdc; color: var(--color-dark); }
.stat-box .stat-icon svg { width: 18px; height: 18px; }
.stat-box .label { font-size: 0.8rem; color: #777; display:flex; justify-content:space-between; }
.stat-box .value { font-size: 1.6rem; font-weight: 700; color: var(--color-dark); margin-top: 4px; }

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.quicklinks { display: flex; flex-wrap: wrap; gap: 10px; }
.quicklinks a { flex: 1 1 45%; text-align: center; display: flex; align-items: center; justify-content: center; gap: 8px; }
.quicklinks a svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ---------------- Avatars ---------------- */
.avatar-svg { display: block; }
.name-with-avatar { display: flex; align-items: center; gap: 8px; }
.name-with-avatar .avatar-svg { width: 28px; height: 28px; }
.topbar .name-with-avatar { color: #fff; }

/* ---------------- Tables that can get wide on mobile ---------------- */
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-responsive table { min-width: 560px; }

/* ---------------- Messaging / chat layout (subject groups, 1-to-1) ---------------- */
.msg-layout { display: flex; gap: 20px; align-items: flex-start; }
.msg-contacts { width: 230px; flex-shrink: 0; max-height: 460px; overflow-y: auto; }
.msg-contacts a { display: block; margin-bottom: 6px; word-break: break-word; }
.msg-pane { flex: 1; min-width: 0; }
.msg-thread { max-height: 400px; overflow-y: auto; border: 1px solid #eee; padding: 10px; border-radius: 8px; }
.msg-thread p { word-break: break-word; }
.msg-send-form { margin-top: 10px; display: flex; gap: 10px; }
.msg-send-form input[type=text] { flex: 1; margin-bottom: 0; }

/* ---------------- Checkbox / assignment lists (group members, teacher subjects) ---------------- */
.checkbox-list { max-height: 260px; overflow-y: auto; border: 1px solid #e2e6de; border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; background: #fbfdf9; }
.checkbox-list label { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--color-text); padding: 4px 0; margin: 0; }
.checkbox-list label input { margin: 0; width: auto; }
.checkbox-list .group-heading { font-weight: 700; color: var(--color-dark); font-size: 0.8rem; text-transform: uppercase; margin-top: 10px; }

/* ---------------- Form rows (side-by-side fields that stack on mobile) ---------------- */
.form-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.form-row > div { flex: 1 1 160px; min-width: 140px; }
.form-row select, .form-row input { margin-bottom: 0; }
.form-row label { margin-bottom: 4px; }

/* ---------------- Timetable ---------------- */
.timetable-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.timetable-tabs a { padding: 6px 14px; border-radius: 20px; font-size: 0.85rem; }

/* ---------------- Responsive breakpoints ---------------- */
@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .hamburger { display: inline-block; }
  .layout { flex-direction: column; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 240px;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.15);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 30px;
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .login-box { margin: 0 16px; }
  table { font-size: 0.85rem; }
  th, td { padding: 8px 6px; }

  .msg-layout { flex-direction: column; }
  .msg-contacts { width: 100%; max-height: 160px; display: flex; flex-wrap: wrap; gap: 6px; }
  .msg-contacts a { flex: 1 1 auto; margin-bottom: 0; }
  .msg-thread { max-height: 300px; }
  .msg-send-form { flex-wrap: wrap; }
  .msg-send-form button { flex: 1 1 100%; }

  .card { padding: 14px; }
  .topbar { padding: 10px 14px; flex-wrap: wrap; row-gap: 8px; }
  .topbar .brand { flex: 1 1 auto; }
  .topbar-right { flex-wrap: wrap; justify-content: flex-end; row-gap: 6px; }
  .topbar .name-with-avatar span.name-text { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .quicklinks a { flex: 1 1 100%; }
  .topbar .brand { font-size: 0.95rem; }
  .form-row > div { flex: 1 1 100%; }
}
