:root {
    --bg: #f8fafc;
    --panel: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --border: #e2e8f0;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 50%, #eef2ff 100%);
    color: var(--text);
    min-height: 100vh;
}

button, input, select {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
}

.app-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0;
}

.loading-card,
.login-card,
.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.login-layout {
    min-height: calc(100vh - 56px);
    display: grid;
    place-items: center;
}

.login-card {
    width: min(460px, 100%);
    padding: 32px;
}

.brand-mark {
    width: 54px;
    height: 54px;
    border-radius: 18px;
    background: var(--text);
    color: white;
    display: grid;
    place-items: center;
    font-weight: 700;
    margin-bottom: 18px;
}

h1, h2, h3 { margin: 0; }
p { color: var(--muted); }

.form-grid {
    display: grid;
    gap: 14px;
    margin-top: 22px;
}

label {
    display: grid;
    gap: 7px;
    color: #334155;
    font-weight: 700;
    font-size: 14px;
}

input, select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    background: #ffffff;
    outline: none;
}

input:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.btn {
    border-radius: 14px;
    padding: 12px 16px;
    background: #e2e8f0;
    color: #0f172a;
    font-weight: 700;
    transition: 0.2s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn:disabled { opacity: 0.65; cursor: not-allowed; transform: none; }

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-bottom: 22px;
}

.topbar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.status-pill {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 12px;
    background: white;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}
.status-online { color: var(--success); }
.status-offline { color: var(--warning); }

.grid-cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.card {
    padding: 18px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.card span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}
.card strong {
    display: block;
    margin-top: 8px;
    font-size: 26px;
}

.panel {
    padding: 22px;
    margin-bottom: 18px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.entry-form {
    display: grid;
    grid-template-columns: 1.4fr 0.7fr 0.7fr 0.7fr auto;
    gap: 12px;
    align-items: end;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

th, td {
    border-bottom: 1px solid var(--border);
    text-align: left;
    padding: 12px 10px;
    font-size: 14px;
}

th {
    color: #334155;
    background: #f8fafc;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 700;
}
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-synced { background: #dcfce7; color: #166534; }
.badge-error { background: #fee2e2; color: #991b1b; }

.alert {
    border-radius: 14px;
    padding: 12px 14px;
    margin-top: 14px;
    font-weight: 700;
}
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-ok { background: #dcfce7; color: #166534; }
.alert-info { background: #dbeafe; color: #1e40af; }

.muted { color: var(--muted); }

@media (max-width: 900px) {
    .grid-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .entry-form { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    .grid-cards { grid-template-columns: 1fr; }
    .entry-form { grid-template-columns: 1fr; }
    .login-card { padding: 24px; }
}

/* V1.1: edición y eliminación sobre el mismo formulario */
.table-actions { display: flex; gap: 6px; white-space: nowrap; }
.btn-small { padding: 7px 10px; border-radius: 8px; font-size: 12px; }
.entry-form { grid-template-columns: 1.4fr 0.7fr 0.7fr 0.7fr auto auto; }
#syncNotice { margin-top: -3px; margin-bottom: 18px; min-height: 18px; font-size: 13px; }
@media (max-width: 900px) { .entry-form { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .entry-form { grid-template-columns: 1fr; } }
