:root {
  --bg: #fafafa;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #6a6a6a;
  --accent: #c93838;
  --accent-soft: #f6e3e3;
  --border: #e2e2e2;
  --error: #b00020;
  --success: #1b5e20;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
.muted { color: var(--muted); }
.error { color: var(--error); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #f0f0f0; padding: 1px 5px; border-radius: 3px; font-size: 0.92em; }

/* --- Auth screen --- */
body.auth {
  display: grid; place-items: center; min-height: 100vh;
  background: linear-gradient(180deg, #fff, #f0f0f0);
}
.card {
  background: var(--card); padding: 32px; border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
  width: min(380px, 92vw);
}
.card h1 { margin: 0 0 6px; }
.card form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.card input {
  font: inherit; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; background: #fff;
}
.card input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.card button {
  font: inherit; padding: 10px 14px; border: 0; border-radius: 6px;
  background: var(--accent); color: #fff; cursor: pointer;
}
.card button:hover { filter: brightness(1.05); }

/* --- Topbar / nav --- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px; background: #fff; border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 18px; }
.topbar h1 a.brand { color: var(--text); }
.topbar nav.primary { display: flex; gap: 4px; flex: 1; }
.topbar nav.primary a {
  color: var(--muted); padding: 6px 12px; border-radius: 6px; font-weight: 500;
}
.topbar nav.primary a:hover { background: #f5f5f5; text-decoration: none; }
.topbar nav.primary a.active { color: var(--accent); background: var(--accent-soft); }
.topbar nav.account { display: flex; align-items: center; gap: 16px; }

.container { padding: 24px; max-width: 1100px; margin: 0 auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin: 0 0 16px; }
.page-header h2 { margin: 0; }

/* --- Dashboard --- */
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 16px;
}
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 18px; display: block; color: inherit;
}
a.stat:hover { border-color: var(--accent); text-decoration: none; }
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat .value { font-size: 32px; font-weight: 600; margin-top: 6px; }

/* --- Buttons / links styled as buttons --- */
.button, .button-link, button[type="submit"] {
  font: inherit; padding: 8px 14px; border: 0; border-radius: 6px;
  background: var(--accent); color: #fff; cursor: pointer; display: inline-block;
}
.button-link { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.button:hover, button[type="submit"]:hover { filter: brightness(1.05); text-decoration: none; }
.button-link:hover { background: #f5f5f5; }

button.link {
  background: transparent; color: var(--accent); padding: 0; border: 0;
  cursor: pointer; font: inherit; text-decoration: underline;
}
button.link.danger { color: var(--error); }

/* --- Forms --- */
.form { display: flex; flex-direction: column; gap: 16px; max-width: 560px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.form input, .form textarea {
  font: inherit; padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; color: var(--text); width: 100%;
}
.form input:focus, .form textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.form small { font-size: 12px; }
.form .actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; }

/* --- Tables --- */
.grid-table {
  width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.grid-table th, .grid-table td {
  padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border);
}
.grid-table th {
  background: #f5f5f5; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--muted);
}
.grid-table tr:last-child td { border-bottom: 0; }
.grid-table td.num, .grid-table th.num { text-align: right; }
.grid-table td.row-actions { white-space: nowrap; display: flex; gap: 12px; align-items: center; }
form.inline { display: inline; margin: 0; }

/* --- Filter bar + tags + file inputs --- */
.filter-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 0 0 16px; padding: 8px 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
}
.filter-bar a {
  color: var(--muted); padding: 4px 10px; border-radius: 4px; font-size: 13px;
}
.filter-bar a:hover { background: #f5f5f5; text-decoration: none; }
.filter-bar a.active { color: var(--accent); background: var(--accent-soft); font-weight: 500; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
}
.tag-global  { background: #e3f2fd; color: #0d47a1; }
.tag-pending { background: #fff3e0; color: #e65100; }
.tag-active  { background: #e6f4ea; color: #1b5e20; }
.tag-stolen  { background: #fdecea; color: #b00020; }
.tag-retired { background: #eeeeee; color: #6a6a6a; }
a.tag-stolen:hover { filter: brightness(0.97); text-decoration: none; }

.tablet-id { font-size: 11px; color: var(--muted); }

.form select {
  font: inherit; padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; color: var(--text); width: 100%;
}
.form input[type="file"] { padding: 6px 0; }
.asset-current {
  padding: 6px 10px; background: #f5f5f5; border-radius: 4px;
  margin-bottom: 4px; font-size: 13px;
}

/* --- Flash messages --- */
.flash {
  padding: 10px 14px; border-radius: 6px; margin: 0 0 16px;
}
.flash-success { background: #e6f4ea; color: var(--success); border: 1px solid #c8e6c9; }
.flash-error   { background: #fdecea; color: var(--error);   border: 1px solid #f5c6cb; }
