/* Modern theme layered on top of app.css. Loaded after Tailwind Play CDN.
   Refines the look of existing class names (.topbar, .container, .form-grid,
   tables, buttons, flashes, etc.) without requiring template rewrites. */

:root {
  --brand: #4f46e5;
  --brand-600: #4338ca;
  --brand-50: #eef2ff;
  --surface: #ffffff;
  --bg: #f8fafc;
  --border: #e5e7eb;
  --text: #0f172a;
  --muted: #64748b;
  --success-bg: #ecfdf5;
  --success-fg: #065f46;
  --error-bg: #fef2f2;
  --error-fg: #991b1b;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --radius: 10px;
  --container-max: 1100px;
  --container-pad: 1.25rem;
}

html, body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Topbar */
.topbar {
  background: linear-gradient(90deg, #0f172a 0%, #1e293b 100%);
  color: #f1f5f9;
  padding: .85rem 1.25rem;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar .brand { font-weight: 700; letter-spacing: -0.01em; font-size: 1.15rem; color: #fff; display: inline-flex; align-items: center; padding: 0; }
.topbar .brand:hover { background: transparent; }
.topbar .brand-logo { height: 50px; width: auto; display: block; }
.topbar a { color: #cbd5e1; font-weight: 500; font-size: .92rem; padding: .35rem .6rem; border-radius: 6px; transition: background .15s, color .15s; margin-right: .1rem; }
.topbar a:hover { background: rgba(255,255,255,.08); color: #fff; }
.topbar a.active { background: #b1002d !important; color: #fff !important; }
.topbar a.active:hover { background: #8e0024 !important; }

/* Icon-only nav items (Alerts bell, Log out). */
.topbar .nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0 !important;
  border-radius: 6px;
  position: relative;
}
.topbar .nav-icon .hicon {
  width: 1.15rem;
  height: 1.15rem;
  /* Invert the black outline SVG so it reads white on the dark topbar. */
  filter: brightness(0) invert(1);
  opacity: .85;
  transition: opacity .15s;
}
.topbar .nav-icon:hover .hicon { opacity: 1; }
.topbar .nav-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 1rem;
  height: 1rem;
  padding: 0 .3rem;
  background: #b1002d;
  color: #fff;
  border-radius: 999px;
  font-size: .65rem;
  font-weight: 700;
  line-height: 1rem;
  text-align: center;
  box-shadow: 0 0 0 2px #1e293b;
}
.topbar .user { color: #94a3b8; font-size: .85rem; margin-left: .5rem; }
.topbar .linklike { color: #f1f5f9; font-weight: 500; }
.topbar .linklike:hover { color: #fff; }

/* Container & headings */
.container { max-width: var(--container-max); padding: 1.5rem var(--container-pad) 3rem; }
h1 { font-size: 1.95rem !important; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 1.25rem !important; }
h2 { font-size: 1.35rem !important; font-weight: 600; letter-spacing: -0.01em; margin-top: 2.5rem !important; margin-bottom: 2.5rem !important; padding: 10px 0; border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; color: cadetblue; }

/* Cards: tables and form-grid become surface cards */
table {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-top: .5rem;
}
th, td { padding: .75rem .9rem; border-bottom: 1px solid var(--border); font-size: .92rem; }
th { background: #f8fafc; color: #475569; font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafafa; }

/* Form card */
.form-grid {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius);
  padding: 1.25rem;
  gap: 1rem;
}
.form-grid label { font-size: .85rem; font-weight: 500; color: #334155; gap: .35rem; }
.form-grid fieldset { border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem 1rem; background: #fafafa; }
.form-grid legend { font-size: .8rem; font-weight: 600; color: #475569; padding: 0 .4rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* Inputs */
body input[type=text], body input[type=email], body input[type=password],
body input[type=number], body input[type=tel], body input[type=date],
body select, body textarea {
  border: 1px solid #d1d5db !important;
  border-radius: 8px !important;
  padding: .55rem .7rem !important;
  background-color: #fff !important;
  color: var(--text) !important;
  font-size: .95rem !important;
  line-height: 1.4 !important;
  width: 100% !important;
  height: auto !important;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}

/* Select: Tailwind's preflight strips the native chevron; restore a custom one. */
body select {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  padding-right: 2.25rem !important;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2364748b' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='5 8 10 13 15 8'/%3e%3c/svg%3e") !important;
  background-repeat: no-repeat !important;
  background-position: right .7rem center !important;
  background-size: 1.1em 1.1em !important;
  cursor: pointer;
  min-height: 2.5rem;
}
body select:focus {
  outline: none !important;
  border-color: var(--brand) !important;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2) !important;
}
body select:disabled { background-color: #f1f5f9 !important; cursor: not-allowed; }
body select::-ms-expand { display: none; }
body select option { color: var(--text); background: #fff; padding: .4rem; font-size: .95rem; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* Buttons */
button, .btn {
  background: #b1002d !important;
  color: #fff !important;
  padding: 5px 12px !important;
  border: 0;
  border-radius: 4px !important;
  font-weight: 500;
  font-size: .92rem;
  box-shadow: var(--shadow-sm);
  transition: background .15s, transform .05s, box-shadow .15s;
}
button, .btn, a.btn, button *, .btn * { color: #fff !important; }
button:hover, .btn:hover, a.btn:hover { background: #8e0024 !important; color: #fff !important; text-decoration: none !important; }
button:active, .btn:active { transform: translateY(1px); }
button.secondary, .btn.secondary, a.btn.secondary { background: #adadad !important; color: #fff !important; border: 0; }
button.secondary:hover, .btn.secondary:hover, a.btn.secondary:hover { background: #757474 !important; color: #fff !important; }
button.danger { background: #685e58 !important; }
button.danger:hover { background: #8e0024 !important; }
button:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; }
.topbar form.inline { margin: 0; display: inline-flex; }
.topbar .linklike {
  background: transparent !important;
  box-shadow: none !important;
  border: 0 !important;
  color: #cbd5e1 !important;
  font-weight: 500 !important;
  font-size: .92rem !important;
  padding: .35rem .6rem !important;
  border-radius: 6px !important;
  text-decoration: none !important;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.topbar .linklike:hover {
  background: rgba(255,255,255,.08) !important;
  color: #fff !important;
  text-decoration: none !important;
}

/* Flashes & errors */
.flash, .errors {
  border-radius: 10px;
  padding: .85rem 1rem;
  border: 1px solid transparent;
  font-size: .92rem;
}
.flash-success { background: var(--success-bg); color: var(--success-fg); border-color: #a7f3d0; }
.flash-error, .errors { background: var(--error-bg); color: var(--error-fg); border-color: #fecaca; }

/* Links inside content */
.container a { color: var(--brand-600); text-decoration: none; }
.container a:hover { text-decoration: underline; }
.row-actions a { color: var(--brand-600); font-weight: 500; display: inline-flex; align-items: center; gap: .25rem; }
.row-actions a .hicon { width: 1.05rem; height: 1.05rem; vertical-align: middle; }
button, .btn { display: inline-flex; align-items: center; gap: .4rem; }
button .hicon, .btn .hicon { width: 1.05rem; height: 1.05rem; filter: brightness(0) invert(1); }

/* Muted & low */
.muted { color: var(--muted); margin: 10px 0; }
.low { color: #b91c1c; font-weight: 600; }

/* Toolbar */
.toolbar { gap: .6rem; margin-bottom: 1rem; }

/* Site footer */
.site-footer {
  max-width: var(--container-max);
  margin: 2rem auto 1rem;
  padding: 0 var(--container-pad);
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
}
.site-footer hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 0 0 1rem;
}
.site-footer p { margin: 0; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  z-index: 100;
}
.modal-backdrop[hidden] { display: none !important; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 25px -5px rgba(0,0,0,.25), 0 10px 10px -5px rgba(0,0,0,.08);
  width: 100%; max-width: 640px;
  max-height: 85vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
}
.modal-body { padding: 1.25rem; overflow-y: auto; }
.modal-body table { margin: .25rem 0; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: .5rem;
  padding: .85rem 1.25rem; border-top: 1px solid var(--border);
  background: #fafafa;
}
.modal-close {
  background: transparent !important;
  color: #475569 !important;
  padding: 0 .35rem !important;
  font-size: 1.5rem !important;
  line-height: 1;
  box-shadow: none !important;
  border-radius: 4px !important;
}
.modal-close:hover { background: #f1f5f9 !important; color: #0f172a !important; }

/* Centered login layout */
.login-wrap {
  min-height: calc(100vh - 160px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 2.25rem;
  width: 100%;
  max-width: 420px;
}
.login-card h1 { margin-bottom: 1.25rem; }

/* Subtle responsive card-ish rows */
@media (max-width: 600px) {
  tr { padding: .75rem .5rem; }
  td { padding: .35rem .5rem; }
}
