:root {
    --bg: #f7f4ef;
    --ink: #1f2126;
    --muted: #6f747f;
    --brand: #cc3f0c;
    --brand-2: #0f7a6b;
    --card: rgba(255, 255, 255, 0.88);
    --line: #d7d2ca;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font-family: "Space Grotesk", sans-serif;
    background: radial-gradient(circle at 12% 18%, #ffeec9 0%, #f7f4ef 40%), linear-gradient(145deg, #f7f4ef, #ecebe7);
}

.bg-glow {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 87% 10%, rgba(204, 63, 12, 0.18), transparent 34%),
        radial-gradient(circle at 12% 85%, rgba(15, 122, 107, 0.2), transparent 38%);
}

.app-shell {
    width: min(1300px, 94vw);
    margin: 2rem auto;
    position: relative;
    z-index: 2;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 1.1rem;
    box-shadow: 0 16px 36px rgba(20, 20, 20, 0.07);
    backdrop-filter: blur(6px);
}

h1, h2, h3 {
    margin: 0 0 .8rem;
    font-family: "Fraunces", serif;
}

label {
    display: block;
    margin-bottom: .6rem;
    font-size: .9rem;
}

input, select, textarea, button {
    width: 100%;
    margin-top: .25rem;
    border-radius: 10px;
    border: 1px solid #c9c5bd;
    padding: .62rem .7rem;
    font: inherit;
}

textarea {
    resize: vertical;
    min-height: 74px;
}

button {
    background: var(--brand);
    color: #fff;
    border: 0;
    cursor: pointer;
    font-weight: 600;
    transition: transform .16s ease, filter .16s ease;
}

button:hover { transform: translateY(-1px); filter: brightness(1.06); }
button.secondary { background: #3d4757; }

.grid-two {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-actions {
    display: flex;
    gap: .6rem;
}

.top-actions button { width: auto; }

.form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .6rem;
    margin-top: .5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: .8rem;
    font-size: .9rem;
}

th, td {
    border-bottom: 1px solid var(--line);
    text-align: left;
    padding: .55rem .35rem;
    vertical-align: top;
}

td button { width: auto; padding: .35rem .5rem; margin-right: .35rem; }

.item-cell {
    display: flex;
    align-items: center;
    gap: .55rem;
}

.item-thumb {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--line);
    background: #fff;
    flex-shrink: 0;
}

.item-thumb-empty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .65rem;
    color: var(--muted);
    background: #f1f1f1;
}

.drag-handle {
    cursor: grab;
    color: #62646b;
}

.dragging-row {
    opacity: .45;
}

#item-device-grid {
    overflow-x: auto;
    margin-top: .7rem;
}

.matrix-table td,
.matrix-table th {
    text-align: center;
}

.matrix-table td:first-child,
.matrix-table th:first-child {
    text-align: left;
    min-width: 220px;
}

#item-device-grid input[type="checkbox"] {
    width: auto;
    margin: 0;
}

#schedule-device-label {
    color: var(--muted);
    margin: 0 0 .6rem;
}

#device-screenshot {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--line);
    margin-top: .7rem;
    display: none;
}

.controls {
    display: grid;
    gap: .5rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mono {
    font-family: "Courier New", monospace;
    white-space: pre-wrap;
    background: #f5f7fb;
    border: 1px solid #d8dee8;
    border-radius: 10px;
    padding: .6rem;
    margin-top: .7rem;
}

.hidden { display: none !important; }
.error { color: #b12222; min-height: 1.25rem; }
.check { display: flex; gap: .5rem; align-items: center; }
.check input { width: auto; margin: 0; }

#schedule-grid {
    display: grid;
    gap: .5rem;
}

.schedule-row {
    display: grid;
    grid-template-columns: 100px 1fr 1fr auto;
    gap: .5rem;
    align-items: center;
}

.twofa-qr {
    margin-top: .8rem;
    display: grid;
    gap: .45rem;
    justify-items: start;
}

.twofa-qr p {
    margin: 0;
}

#user-twofa-qr {
    width: 220px;
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    padding: .35rem;
}

@media (max-width: 920px) {
    .grid-two { grid-template-columns: 1fr; }
    .schedule-row { grid-template-columns: 1fr 1fr; }
}
