* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: #f5f6f8; color: #222; }
a { color: #1f3a8a; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { background: #fff; padding: 32px; border-radius: 12px; width: 100%; max-width: 380px; box-shadow: 0 6px 30px rgba(0,0,0,.08); }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .sub { color: #666; margin-bottom: 24px; font-size: 14px; }

/* Forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: #444; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #d6d8dc; border-radius: 8px;
  font-size: 14px; outline: none; background: #fff; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: #2a6df4; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* Buttons */
.btn { background: #1f3a8a; color: #fff; border: 0; padding: 9px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 14px; }
.btn:hover { background: #16306e; }
.btn:disabled { background: #9ca3af; cursor: not-allowed; }
.btn.secondary { background: #e5e7eb; color: #111; }
.btn.secondary:hover { background: #d1d5db; }
.btn.danger { background: #b91c1c; }
.btn.danger:hover { background: #991b1b; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.link { background: none; color: #1f3a8a; padding: 0; }
.btn.link:hover { background: none; text-decoration: underline; }

.error { color: #b91c1c; font-size: 13px; margin-top: 8px; }
.muted { color: #6b7280; font-size: 13px; }

/* Layout */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: #1f3a8a; color: #cbd5ff; padding: 20px 14px; }
.sidebar h2 { color: #fff; font-size: 15px; margin: 0 0 18px; line-height: 1.3; }
.sidebar a { display: block; padding: 8px 10px; color: #cbd5ff; text-decoration: none; border-radius: 6px; font-size: 14px; margin-bottom: 2px; }
.sidebar a:hover, .sidebar a.active { background: rgba(255,255,255,.12); color: #fff; }
.sidebar .footer { margin-top: 40px; font-size: 12px; color: #95a3d6; }
.main { padding: 22px 28px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.topbar h1 { font-size: 20px; margin: 0; }
.actions { display: flex; gap: 8px; align-items: center; }
.search { padding: 8px 11px; border: 1px solid #d6d8dc; border-radius: 8px; font-size: 14px; min-width: 220px; outline: none; }
.search:focus { border-color: #2a6df4; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.card { background: #fff; padding: 16px; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.04); }
.card .label { font-size: 12px; color: #666; text-transform: uppercase; letter-spacing: .5px; }
.card .value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.panel { background: #fff; padding: 18px; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.04); margin-bottom: 16px; }
.panel h3 { margin: 0 0 12px; font-size: 14px; text-transform: uppercase; letter-spacing: .5px; color: #555; }

/* Tables */
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.04); }
th, td { text-align: left; padding: 9px 11px; font-size: 13px; border-bottom: 1px solid #eef0f3; }
th { background: #fafbfc; font-weight: 600; color: #555; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-link { cursor: pointer; }
.row-link:hover { background: #f6f8fb; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: .3px; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.bad { background: #fee2e2; color: #991b1b; }
.badge.muted { background: #e5e7eb; color: #374151; }
.badge.info { background: #dbeafe; color: #1e40af; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; box-shadow: 0 12px 40px rgba(0,0,0,.2); }
.modal .head { padding: 16px 20px; border-bottom: 1px solid #eef0f3; display: flex; justify-content: space-between; align-items: center; }
.modal .head h3 { margin: 0; font-size: 16px; }
.modal .body { padding: 18px 20px; }
.modal .foot { padding: 14px 20px; border-top: 1px solid #eef0f3; display: flex; justify-content: flex-end; gap: 8px; }
.modal-large { max-width: 860px; }

/* Toast */
.toast { position: fixed; bottom: 18px; right: 18px; background: #111827; color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 13px; box-shadow: 0 8px 30px rgba(0,0,0,.2); z-index: 100; }
.toast.bad { background: #991b1b; }
