/* === Reset === */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: #f3f4f6;
    color: #111827;
    line-height: 1.5;
    font-size: 14px;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Login === */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
}
.login-box {
    background: white;
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    text-align: center;
}
.login-logo { font-size: 48px; margin-bottom: 8px; }
.login-box h1 { font-size: 20px; margin-bottom: 4px; }
.login-box .muted { margin-bottom: 24px; }
.login-box form { text-align: left; }
.btn-block { width: 100%; padding: 12px; font-size: 15px; margin-top: 8px; }

/* === Top bar === */
.topbar {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 0 24px;
    display: flex;
    align-items: center;
    height: 56px;
}
.brand {
    color: #111827;
    font-weight: 700;
    font-size: 16px;
    text-decoration: none;
    margin-right: 32px;
}
.topnav {
    display: flex;
    gap: 4px;
    flex: 1;
}
.topnav a {
    color: #6b7280;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}
.topnav a:hover { background: #f3f4f6; color: #111827; }
.topnav a.active { background: #eff6ff; color: #1d4ed8; }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-info { color: #6b7280; font-size: 13px; }
.user-info small { color: #9ca3af; }

/* === Layout === */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}
.page-title { font-size: 22px; margin-bottom: 16px; font-weight: 700; }
.page-header { margin-bottom: 16px; }

.muted { color: #6b7280; }
.stale { color: #d97706; font-style: italic; }
.center { text-align: center; }
.right { text-align: right; }

/* === Cards === */
.card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid #e5e7eb;
}
.card h2 {
    font-size: 16px;
    margin-bottom: 12px;
    color: #111827;
    font-weight: 600;
}
.card h3 {
    font-size: 14px;
    margin: 16px 0 8px;
    color: #374151;
    font-weight: 600;
}
details.card summary {
    cursor: pointer;
    margin: -20px;
    padding: 20px;
    user-select: none;
}
details[open].card summary {
    margin-bottom: 0;
    border-bottom: 1px solid #f3f4f6;
    padding-bottom: 12px;
}
details[open].card form { padding-top: 16px; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.secret-card { background: #fef3c7; border-color: #fcd34d; }
.secret-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d97706;
    border-radius: 6px;
    font-family: Consolas, monospace;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

/* === Metrics === */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.metric {
    background: white;
    padding: 18px 20px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
}
.metric-label {
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.metric-value {
    font-size: 32px;
    font-weight: 700;
    color: #111827;
    margin: 4px 0;
}
.metric-value.danger { color: #dc2626; }
.metric-sub { font-size: 12px; color: #6b7280; }
.metric-sub.warn { color: #d97706; font-weight: 600; }

/* === Tables === */
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th, .data-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: top;
}
.data-table th {
    font-size: 12px;
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}
.data-table th.right, .data-table td.right { text-align: right; }
.data-table tbody tr:hover { background: #f9fafb; }
.data-table code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.kv-table {
    width: 100%;
    border-collapse: collapse;
}
.kv-table td {
    padding: 6px 0;
    font-size: 14px;
    vertical-align: top;
}
.kv-table td:first-child {
    color: #6b7280;
    width: 140px;
}

/* === Badges === */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
.badge-green { background: #d1fae5; color: #065f46; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f3f4f6; color: #4b5563; }

/* === Forms === */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    align-items: start;
}
.form-grid h2 {
    grid-column: 1 / -1;
    margin-top: 8px;
}
.form-grid .form-actions {
    grid-column: 1 / -1;
}
.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

form label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 12px;
}
form input[type=text],
form input[type=password],
form input[type=email],
form input[type=number],
form select,
form textarea {
    width: 100%;
    padding: 8px 10px;
    margin-top: 4px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    color: #111827;
}
form input:focus,
form select:focus,
form textarea:focus {
    outline: 2px solid #2563eb;
    outline-offset: -1px;
    border-color: #2563eb;
}
form .hint {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    font-weight: 400;
    color: #9ca3af;
}
form input[type=checkbox] { margin-right: 6px; }

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 7px 14px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    background: white;
    color: #111827;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn-primary { background: #2563eb; color: white; border-color: #2563eb; }
.btn-primary:hover { background: #1d4ed8; color: white; }
.btn-danger { background: white; color: #dc2626; border-color: #fca5a5; }
.btn-danger:hover { background: #fef2f2; }
.btn-ghost { border: none; background: transparent; color: #6b7280; }
.btn-ghost:hover { background: #f3f4f6; color: #111827; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* === Messages === */
.msg {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}
.msg.success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.msg.error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.msg.warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.msg.info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* === Printer cards en detalle de tienda === */
.printer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}
.pcard {
    background: white;
    border: 1px solid #e5e7eb;
    border-top: 3px solid #9ca3af;
    border-radius: 8px;
    padding: 12px;
}
.pcard-ok { border-top-color: #22c55e; }
.pcard-error { border-top-color: #ef4444; border-color: #fca5a5; }
.pcard-offline { border-top-color: #9ca3af; opacity: 0.7; }
.pcard-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}
.pcard-name { font-weight: 600; font-size: 14px; }
.pcard-ip { font-size: 11px; color: #9ca3af; }
.pcard-stats {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
}
.pcard-meta { margin-top: 6px; font-size: 11px; color: #9ca3af; }
.pill {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
    background: #d1fae5;
    color: #065f46;
}
.pill-error { background: #fee2e2; color: #991b1b; }
.pill-offline { background: #f3f4f6; color: #4b5563; }

.display-msg {
    background: #111827;
    color: #34d399;
    padding: 6px 10px;
    border-radius: 4px;
    font-family: Consolas, monospace;
    font-size: 11px;
    margin: 6px 0;
}

/* === Code blocks === */
.code-block {
    background: #1f2937;
    color: #f9fafb;
    padding: 12px 16px;
    border-radius: 6px;
    font-family: Consolas, monospace;
    font-size: 13px;
    overflow-x: auto;
    margin: 8px 0;
    white-space: pre-wrap;
    word-break: break-all;
}

/* === Footer === */
.footer {
    margin: 40px 24px 20px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
    color: #9ca3af;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 768px) {
    .topnav { display: none; }
    .container { padding: 12px; }
    .metric-grid { grid-template-columns: 1fr 1fr; }
}
