/* Magnet-Me Admin — minimal stylesheet. Internal tool, prioritise legibility. */

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #F5F6F8;
    color: #1F2937;
    font-size: 14px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: #ffffff;
    border-bottom: 1px solid #E5E7EB;
}
.topbar .brand a {
    color: #1F2937;
    font-weight: 600;
    text-decoration: none;
    font-size: 15px;
}
.topbar .nav { display: flex; gap: 16px; align-items: center; }
.topbar .nav a {
    color: #4B5563;
    text-decoration: none;
}
.topbar .nav a:hover { color: #111827; }
.topbar .nav .who { color: #6B7280; font-size: 12px; }
.topbar .nav form.inline { margin: 0; }
.topbar .nav form button.link {
    background: none;
    border: 0;
    color: #4B5563;
    cursor: pointer;
    padding: 0;
    font: inherit;
}
.topbar .nav form button.link:hover { color: #111827; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

.footer {
    text-align: center;
    color: #9CA3AF;
    font-size: 12px;
    padding: 24px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 20px;
}
.page-header h1 { margin: 0 0 4px 0; font-size: 24px; font-weight: 600; }
.muted { color: #6B7280; }

.card {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.login-card {
    max-width: 380px;
    margin: 80px auto;
}
.login-card h1 { margin-top: 0; }
.field { margin: 16px 0; display: flex; flex-direction: column; gap: 4px; }
.field input {
    padding: 8px 10px;
    font: inherit;
    border: 1px solid #D1D5DB;
    border-radius: 4px;
}

.btn {
    padding: 8px 16px;
    border-radius: 4px;
    border: 0;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
}
.btn.primary { background: #1E66D6; color: #fff; }
.btn.primary:hover { background: #174FA8; }

.alert {
    padding: 10px 12px;
    border-radius: 6px;
    margin: 12px 0;
    font-size: 13px;
}
.alert.error { background: #FEE2E2; color: #7A1F1F; border: 1px solid #FCA5A5; }
.alert.info  { background: #E8F0FE; color: #1B3A66; border: 1px solid #B6CDF7; }

.grid {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    overflow: hidden;
}
.grid th, .grid td {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid #F3F4F6;
}
.grid thead { background: #F9FAFB; }
.grid th { font-weight: 600; color: #4B5563; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.grid tr:last-child td { border-bottom: 0; }
.grid td.empty { text-align: center; padding: 32px; color: #9CA3AF; }
.grid td.mono, .mono { font-family: Consolas, "Courier New", monospace; font-size: 12px; }
.grid td.small, .small { font-size: 11px; }

.status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.status-active   { background: #DCFCE7; color: #155F2C; }
.status-expired  { background: #FEF3C7; color: #7A5A11; }
.status-blocked  { background: #FEE2E2; color: #7A1F1F; }
.status-archived { background: #E5E7EB; color: #4B5563; margin-left: 4px; }

/* ---- Forms / details / action cards ---- */

.btn.secondary {
    background: #fff;
    color: #4B5563;
    border: 1px solid #D1D5DB;
}
.btn.secondary:hover { background: #F9FAFB; }
.btn.danger {
    background: #DC2626;
    color: #fff;
    border: 0;
}
.btn.danger:hover { background: #B91C1C; }
.btn.link-back {
    color: #4B5563;
    text-decoration: none;
    margin-right: 8px;
    background: none;
    padding: 6px 10px;
}
.btn.link-back:hover { color: #111827; }
a.btn { display: inline-block; }

.form-grid { display: flex; flex-direction: column; gap: 16px; max-width: 880px; }
.form-row  { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-row > .field { margin: 0; }

.field textarea {
    padding: 8px 10px;
    font: inherit;
    border: 1px solid #D1D5DB;
    border-radius: 4px;
    resize: vertical;
}
.field select {
    padding: 8px 10px;
    font: inherit;
    border: 1px solid #D1D5DB;
    border-radius: 4px;
    background: #fff;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 4px;
}
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    cursor: pointer;
    font-weight: normal;
}
.checkbox-row input[type=checkbox] { accent-color: #1E66D6; }

.action-bar {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
    padding-top: 12px;
    border-top: 1px solid #F3F4F6;
}

.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 1000px) {
    .details-grid { grid-template-columns: 1fr; }
}
.action-column { display: flex; flex-direction: column; gap: 12px; }
.action-card { padding: 14px; }
.action-card h2.section { margin: 0 0 4px 0; font-size: 14px; font-weight: 600; }
.action-card .inline-form { margin-top: 8px; display: flex; flex-direction: column; gap: 10px; }
.action-card .inline-form button { align-self: flex-start; }

.section { font-size: 14px; font-weight: 600; margin: 0 0 12px 0; }
.section.small { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: #6B7280; margin-top: 16px; }

.kv {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 6px 16px;
    margin: 0;
}
.kv dt { color: #6B7280; font-size: 12px; padding-top: 2px; }
.kv dd { margin: 0; font-size: 13px; }

.chip-list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    display: inline-block;
    padding: 3px 10px;
    background: #E0E7FF;
    color: #1E3A8A;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.sub-section { margin-top: 16px; }

.grid.clickable-rows tbody tr:hover { background: #F3F6FB; }

/* ---- Tab navigation ---- */
.tab-nav {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #E5E7EB;
    margin-bottom: 16px;
}
.tab-nav a.tab {
    padding: 8px 18px;
    text-decoration: none;
    color: #4B5563;
    font-weight: 500;
    font-size: 13px;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.12s;
}
.tab-nav a.tab:hover { color: #111827; }
.tab-nav a.tab.active {
    color: #1E66D6;
    border-bottom-color: #1E66D6;
    font-weight: 600;
}
.badge {
    display: inline-block;
    background: #E5E7EB;
    color: #4B5563;
    border-radius: 999px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 5px;
}
.tab-nav a.tab.active .badge {
    background: #DBEAFE;
    color: #1E66D6;
}

/* ---- Tight buttons (used inside table rows) ---- */
.btn.tight { padding: 4px 10px; font-size: 11px; }
.row-actions { white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.row-actions form.inline { margin: 0; }

/* ---- Promo / pack section links ---- */
.link-row {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.link-row .btn .muted {
    margin-left: 6px;
    font-size: 11px;
    font-weight: normal;
}

/* ---- Audit log viewer ---- */
.filter-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 16px;
    max-width: 500px;
}
.filter-form .field { flex: 1; }

.status-action {
    background: #E0E7FF;
    color: #1E3A8A;
}

details.audit-diff > summary {
    cursor: pointer;
    user-select: none;
}
details.audit-diff[open] > summary { margin-bottom: 4px; }
details.audit-diff pre {
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 4px;
    padding: 8px;
    font-size: 11px;
    margin: 4px 0;
    max-width: 500px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ---- Reports page totals row ---- */
.totals-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 16px 0;
}
@media (max-width: 720px) {
    .totals-row { grid-template-columns: 1fr 1fr; }
}
.totals-card {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 14px 16px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.totals-value {
    font-size: 22px;
    font-weight: 600;
    color: #1F2937;
    margin-top: 4px;
}
.totals-value.money {
    color: #1E7A3C;
}
.totals-value.small {
    font-size: 13px;
    font-weight: 500;
}

td.money, .money {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* ---- Index filter bar ---- */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    align-items: center;
}
.filter-bar .filter-search {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #D1D5DB;
    border-radius: 4px;
    font: inherit;
}
.filter-bar .filter-select {
    padding: 8px 10px;
    border: 1px solid #D1D5DB;
    border-radius: 4px;
    font: inherit;
    background: #fff;
}

/* ---- Bulk-action bar ---- */
.bulk-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    background: #FFF7E1;
    border: 1px solid #F1D182;
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 8px;
}
.bulk-bar .bulk-count { font-weight: 600; color: #7A5A11; }
.bulk-bar .bulk-reason {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #D1D5DB;
    border-radius: 4px;
    font: inherit;
}
.bulk-bar .bulk-extend { display: flex; gap: 4px; align-items: center; }
.bulk-bar .bulk-days {
    width: 60px;
    padding: 6px 8px;
    border: 1px solid #D1D5DB;
    border-radius: 4px;
    font: inherit;
}

/* ---- Row checkboxes ---- */
.col-check {
    width: 28px;
    text-align: center;
}
.col-check input[type=checkbox] { accent-color: #1E66D6; cursor: pointer; }

/* ---- Color-coded expiry cells ---- */
td.exp-perpetual { color: #6B7280; font-weight: 600; text-align: center; }
td.exp-past      { color: #B91C1C; font-weight: 600; }
td.exp-soon      { color: #B45309; font-weight: 600; }
td.exp-warn      { color: #7A5A11; }
td.exp-ok        { color: #4B5563; }

/* ---- Activation code display ---- */
.activation-code {
    font-family: Consolas, "Courier New", monospace;
    font-size: 16px;
    letter-spacing: 0.08em;
    background: #F3F4F6;
    border: 1px solid #D1D5DB;
    padding: 6px 10px;
    border-radius: 4px;
    display: inline-block;
    user-select: all;
}
.qr-block {
    display: inline-block;
    padding: 8px;
    background: #fff;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
}
.qr-block svg, .qr-block canvas { display: block; }

/* ---- Tag chips ---- */
.tag-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 1px rgba(0,0,0,0.20);
    text-decoration: none;
    line-height: 1.4;
    margin-right: 4px;
    margin-top: 2px;
    white-space: nowrap;
}
a.tag-chip:hover {
    filter: brightness(1.1);
    color: #fff;
}
.row-tags {
    display: flex;
    flex-wrap: wrap;
    margin-top: 4px;
}

/* Tags-index per-row Edit dropdown */
.tag-edit summary {
    list-style: none;
    cursor: pointer;
    display: inline-block;
}
.tag-edit summary::-webkit-details-marker { display: none; }
.tag-edit-body {
    margin-top: 8px;
    padding: 10px;
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    min-width: 240px;
}
.tag-edit-body .field { margin: 6px 0; }
.tag-edit-body .field label { font-size: 11px; color: #6B7280; }
.tag-edit-body .field input {
    padding: 5px 8px;
    border: 1px solid #D1D5DB;
    border-radius: 4px;
    font: inherit;
    font-size: 12px;
}
.color-input {
    width: 60px;
    height: 32px;
    padding: 2px;
    border: 1px solid #D1D5DB;
    border-radius: 4px;
    cursor: pointer;
}

/* Bulk-bar tag picker */
.bulk-tag {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}
.bulk-tag .bulk-tag-select {
    padding: 5px 8px;
    border: 1px solid #D1D5DB;
    border-radius: 4px;
    font: inherit;
    font-size: 12px;
}

/* ---- Reports date presets ---- */
.date-presets {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.date-presets a {
    padding: 4px 10px;
    background: #F3F4F6;
    border: 1px solid #E5E7EB;
    border-radius: 4px;
    color: #4B5563;
    font-size: 12px;
    text-decoration: none;
}
.date-presets a:hover { background: #E5E7EB; color: #111827; }
.date-presets a.active {
    background: #1E66D6;
    color: #fff;
    border-color: #1E66D6;
}
