*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
  font-size: 15px;
}

/* ── Header ── */
.site-header {
  background: #1e3a5f;
  color: #fff;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.header-inner {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-title { font-size: 1.15rem; font-weight: 700; letter-spacing: 0.01em; }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-user { font-size: 0.85rem; opacity: 0.75; }
.back-link {
  color: #a8c4e0;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}
.back-link:hover { color: #fff; }

/* ── Main ── */
.main {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}
.form-main { max-width: 640px; }
.page-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-top h2 { font-size: 1.4rem; font-weight: 700; }
.section-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 28px 0 14px;
}
.section-top h3 { font-size: 1.1rem; font-weight: 600; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover  { opacity: 0.88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary   { background: #2980b9; color: #fff; }
.btn-secondary { background: #e8edf3; color: #1e3a5f; }
.btn-danger    { background: #e74c3c; color: #fff; }
.btn-ghost     { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.35); }
.btn-ghost:hover { background: rgba(255,255,255,0.1); }
.btn-sm  { padding: 6px 14px; font-size: 0.82rem; }
.btn-xs  { padding: 4px 10px; font-size: 0.78rem; border-radius: 5px; }
.btn-full { width: 100%; justify-content: center; }

.btn-ghost.btn-xs { color: #555; border-color: #ccc; }
.btn-ghost.btn-xs:hover { background: #f0f0f0; color: #333; }
.text-danger { color: #e74c3c !important; }

/* ── Login ── */
.login-page {
  background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 100%);
}
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 24px 24px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  text-align: center;
}
.login-icon { font-size: 2.8rem; margin-bottom: 12px; }
.login-card h1 { font-size: 1.6rem; margin-bottom: 6px; color: #1e3a5f; }
.login-sub { color: #666; font-size: 0.88rem; margin-bottom: 28px; }
.login-register { margin-top: 18px; font-size: 0.88rem; color: #666; text-align: center; }
.login-register a { color: #2980b9; text-decoration: none; font-weight: 600; }
.login-register a:hover { text-decoration: underline; }
.login-card .field { text-align: left; }

/* ── Fields ── */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 0; }

label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #444;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.optional { font-weight: 400; text-transform: none; color: #999; font-size: 0.8rem; }

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
select,
textarea {
  padding: 10px 12px;
  border: 1.5px solid #d0d7de;
  border-radius: 7px;
  font-size: 0.95rem;
  font-family: inherit;
  color: #1a1a2e;
  background: #fff;
  transition: border-color 0.15s;
  width: 100%;
  min-width: 0;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #2980b9;
  box-shadow: 0 0 0 3px rgba(41,128,185,0.15);
}
textarea { resize: vertical; }

.input-prefix-wrap { position: relative; }
.input-prefix {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #888;
  font-weight: 600;
  pointer-events: none;
}
.input-prefix-wrap input { padding-left: 24px; }

/* ── Form card ── */
.form-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  margin-top: 16px;
}
.form-sub { color: #555; margin: 4px 0 0; font-size: 0.9rem; }
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}
.form-actions .btn-ghost {
  color: #555;
  border: 1px solid #ccc;
  background: transparent;
}
.form-actions .btn-ghost:hover { background: #f0f2f5; color: #333; }
.form-error { color: #e74c3c; font-size: 0.88rem; margin-bottom: 12px; font-weight: 500; }

fieldset.next-due-group {
  border: 1.5px solid #e0e7ef;
  border-radius: 9px;
  padding: 16px;
  margin-top: 4px;
  margin-bottom: 4px;
}
fieldset.next-due-group legend {
  font-size: 0.82rem;
  font-weight: 600;
  color: #444;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 6px;
}
fieldset.next-due-group .field-row { margin-bottom: 0; }
fieldset.next-due-group .field { margin-bottom: 0; }

/* ── Asset grid ── */
.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.asset-card {
  background: #fff;
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  text-decoration: none;
  color: inherit;
  border: 2px solid transparent;
  display: block;
  transition: box-shadow 0.15s, transform 0.1s, border-color 0.15s;
}
.asset-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); transform: translateY(-2px); }
.asset-card.overdue  { border-color: #e74c3c; }
.asset-card.due-soon { border-color: #e67e22; }

.asset-card-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.asset-icon { font-size: 2rem; line-height: 1; flex-shrink: 0; margin-top: 2px; }
.asset-info { flex: 1; }
.asset-name { font-size: 1rem; font-weight: 700; color: #1e3a5f; line-height: 1.3; }
.asset-type { font-size: 0.78rem; color: #888; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }

.asset-card-body { padding-top: 12px; border-top: 1px solid #f0f0f0; }
.asset-meta { display: flex; gap: 8px; align-items: baseline; margin-bottom: 5px; font-size: 0.88rem; color: #333; }
.meta-label { font-size: 0.75rem; font-weight: 600; color: #999; text-transform: uppercase; letter-spacing: 0.04em; min-width: 70px; }
.asset-meta.no-records { color: #aaa; font-style: italic; }
.asset-count { font-size: 0.78rem; color: #aaa; margin-top: 8px; }
.text-overdue { color: #e74c3c; font-weight: 600; }
.text-soon    { color: #e67e22; font-weight: 600; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}
.badge-overdue { background: #fdecea; color: #c0392b; }
.badge-soon    { background: #fef3e2; color: #c0392b; color: #d35400; }

/* ── Asset detail header ── */
.asset-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 6px;
}
.asset-header-icon { font-size: 2.4rem; line-height: 1; flex-shrink: 0; }
.asset-header h2   { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.asset-type-label  { font-size: 0.8rem; color: #888; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.asset-header-actions { display: flex; gap: 8px; margin-left: auto; flex-shrink: 0; }

.asset-header .btn-secondary { color: #1e3a5f; }
.asset-header .btn-danger    { }

.asset-notes { color: #555; font-size: 0.9rem; margin: 10px 0 0; line-height: 1.55; }

/* ── Records ── */
.records-list { display: flex; flex-direction: column; gap: 12px; }
.record-card {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  border-left: 4px solid #d0d7de;
}
.record-card.overdue   { border-left-color: #e74c3c; border: 2px solid #e74c3c; }
.record-card.due-soon  { border-left-color: #e67e22; border: 2px solid #e67e22; }
.record-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 12px;
}
.record-date-type { display: flex; flex-direction: column; gap: 3px; }
.record-date { font-size: 0.8rem; color: #888; font-weight: 500; }
.record-type { font-size: 1rem; font-weight: 700; color: #1e3a5f; }
.record-actions { display: flex; gap: 6px; flex-shrink: 0; }
.record-meta-row { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 8px; }
.record-meta { display: flex; gap: 6px; align-items: baseline; font-size: 0.88rem; }
.record-notes { font-size: 0.88rem; color: #555; line-height: 1.5; margin-top: 6px; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #888;
}
.empty-state.small { padding: 30px 20px; }
.empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { margin-bottom: 18px; }

/* ── Flash ── */
.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  font-weight: 500;
}
.flash-success  { background: #d4edda; color: #155724; }
.flash-info     { background: #d1ecf1; color: #0c5460; }
.flash-overdue  { background: #fdecea; color: #c0392b; font-weight: 600; }
.flash-soon     { background: #fef3e2; color: #d35400; font-weight: 600; }

/* ── 2-column form grid ── */
.form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-2col .span-2 { grid-column: 1 / -1; }

/* ── Footer ── */
.site-footer {
  text-align: center;
  padding: 28px 20px;
  margin-top: 48px;
  border-top: 1px solid #e0e4ea;
  color: #aaa;
  font-size: 0.85rem;
}


/* ── Responsive ── */
@media (max-width: 520px) {
  .asset-grid { grid-template-columns: 1fr; }
  .field-row  { grid-template-columns: 1fr; }
  .form-2col  { grid-template-columns: 1fr; }
  .form-2col .span-2 { grid-column: 1; }
  .form-card  { padding: 16px; }
  .asset-header-actions { flex-direction: column; }
}
