:root {
  --green-dark: rgb(76, 139, 50);
  --green-mid: rgb(96, 169, 70);
  --green-light: rgb(133, 181, 68);
  --box-bg: #f7f7f7;
  --warning: #f0ad4e;
  --warning-hover: #ec971f;
  --text: #333;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: #ecf0f5;
}

a { color: var(--green-mid); text-decoration: none; }
a:hover { color: var(--green-mid); text-decoration: underline; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--green-dark);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  height: 50px;
}

.topbar .brand {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
}

.topbar nav a {
  color: #fff;
  padding: 15px 12px;
  display: inline-block;
}

.topbar nav a:hover,
.topbar nav a.active {
  background: var(--green-mid);
  text-decoration: none;
}

.topbar .account {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  margin-left: auto;
}

.btn-account {
  display: inline-block;
  background: var(--green-mid);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
}
.btn-account:hover { 
  background: var(--green-light);
  color: #fff;
  text-decoration: none;
 }

/* ---------- Layout ---------- */
.container {
  max-width: 1400px;
  margin: 20px auto;
  padding: 0 15px;
}

.tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.search-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}
.search-bar input[type=text],
.search-bar input[type=date],
.search-bar select {
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 14px;
}
.search-bar input[type=text] { flex: 1 1 280px; }
.search-bar select { flex: 0 1 220px; }
.search-bar label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.muted { color: #999; }

/* ---------- Tile / box ---------- */
.box {
  background: var(--box-bg);
  border: 1px solid var(--green-light);
  border-radius: 5px;
  padding: 0;
  overflow: hidden;
  /* Cards in the same grid row stretch to equal height (grid default) —
     laying them out as a column keeps the footer/button pinned to the
     bottom-right instead of trailing right after a short description. */
  height: 100%;
  display: flex;
  flex-direction: column;
}

.box-header {
  background: var(--green-light);
  color: #fff;
  padding: 10px 15px;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.box-body { padding: 12px 15px; flex: 1 1 auto; }
.box-body p { margin: 6px 0; }

.resources-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
  margin: 10px 0;
}
.resources-grid img { vertical-align: middle; margin-right: 4px; }
.resources-grid .muted { color: #999; font-size: 13px; }

.box-footer {
  text-align: right;
  padding: 0 15px 12px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  border: none;
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 3px;
  cursor: pointer;
}

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: var(--warning-hover); }

.btn-custom { background: #4CAF50; color: #fff; padding: 10px 20px; font-size: 16px; }
.btn-custom:hover { background: #45a049; }

.btn-primary { background: var(--green-mid); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }

.btn-danger { background: #d9534f; color: #fff; }
.btn-danger:hover { background: #c9302c; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-icon { padding: 8px 10px; line-height: 1; }

/* ---------- Forms ---------- */
.form-box {
  background: #fff;
  border: 1px solid var(--green-light);
  border-radius: 5px;
  max-width: 700px;
  margin: 0 auto;
}
.form-box .box-header { border-radius: 5px 5px 0 0; }
.form-box .box-body { padding: 20px; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 14px; }
.form-group input[type=text],
.form-group input[type=url],
.form-group input[type=email],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 14px;
}
.form-group textarea { min-height: 80px; resize: vertical; }
.form-group select[multiple] { min-height: 130px; }

.icon-row { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; align-items: end; }
.icon-preview { font-size: 24px; text-align: center; padding-bottom: 8px; }

.form-actions { display: flex; gap: 10px; margin: 16px 0; }

/* ---------- Auth gate ---------- */
.auth-gate {
  max-width: 500px;
  margin: 60px auto;
  text-align: center;
  background: #fff;
  border: 1px solid var(--green-light);
  border-radius: 5px;
  padding: 40px;
}

table.users-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}
table.users-table th, table.users-table td {
  text-align: left;
  padding: 5px 5px;
  border-bottom: 1px solid #eee;
  font-size: 14px;
}
table.users-table td button + button { margin-left: 6px; }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 16px;
  font-size: 14px;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: normal;
  font-size: 14px;
}

.msg { padding: 10px 15px; border-radius: 3px; margin-bottom: 15px; font-size: 14px; }
.msg-error { background: #f2dede; color: #a94442; }
.msg-success { background: #dff0d8; color: #3c763d; }

.hidden { display: none !important; }

/* ---------- Modal (Edit / Delete tile) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  overflow-y: auto;
}
.modal-box {
  background: #fff;
  border-radius: 5px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-box .box-header { border-radius: 5px 5px 0 0; position: relative; }
.modal-box .box-body { padding: 20px; }
.modal-box-small { max-width: 480px; }
.modal-close {
  position: absolute;
  right: 10px;
  top: 8px;
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.session-debug {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px dashed #ccc;
  font-size: 12px;
  color: #888;
  font-family: Consolas, Monaco, monospace;
}
