* { box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0; padding: 0;
    background: #f5f5f5; color: #333;
}
header {
    background: #fff; color: #1a1a2e;
    padding: 0.8rem 2rem;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid #e0e0e0;
}
header .brand { display: flex; align-items: center; gap: 0.8rem; }
header .brand img { height: 40px; width: auto; display: block; }
header h1 { margin: 0; font-size: 1.15rem; font-weight: 500; color: #1a1a2e; }
header .user-info { font-size: 0.9rem; color: #555; }
header button {
    background: transparent; color: #1a1a2e;
    border: 1px solid #ccc; padding: 0.3rem 0.8rem;
    border-radius: 4px; cursor: pointer; font-size: 0.85rem; margin-left: 1rem;
}
header button:hover { background: #f0f0f0; }
main { max-width: 1200px; margin: 2rem auto; padding: 0 1rem; }
.card {
    background: white; border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 2rem; margin-bottom: 1rem;
}
.card.login { max-width: 420px; margin: 4rem auto; }
.card.login .logo-container { text-align: center; margin-bottom: 1.5rem; }
.card.login .logo-container img { height: 80px; width: auto; }
h2 { margin-top: 0; font-weight: 500; }
label { display: block; margin-bottom: 0.3rem; font-size: 0.9rem; color: #555; }
input[type="email"], input[type="password"] {
    width: 100%; padding: 0.6rem; border: 1px solid #ccc;
    border-radius: 4px; font-size: 1rem; margin-bottom: 1rem; font-family: inherit;
}
button.primary {
    background: #1a1a2e; color: white; border: none;
    padding: 0.7rem 1.5rem; border-radius: 4px;
    cursor: pointer; font-size: 1rem; width: 100%;
}
button.primary:hover { background: #2a2a4e; }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }
.error {
    color: #c00; background: #fee; padding: 0.8rem;
    border-radius: 4px; margin-bottom: 1rem; font-size: 0.9rem;
}
.info {
    color: #036; background: #e6f3ff; padding: 0.8rem;
    border-radius: 4px; margin-bottom: 1rem; font-size: 0.9rem;
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.7rem 0.5rem; border-bottom: 1px solid #eee; }
th { font-weight: 500; color: #666; font-size: 0.85rem; text-transform: uppercase; }
tr { cursor: pointer; }
tr:hover { background: #fafafa; }
tr.selected { background: #e6f3ff; box-shadow: inset 3px 0 0 #036; }
tr.selected:hover { background: #d9ecff; }
button.download {
    background: #2a6e3f; color: white; border: none;
    padding: 0.4rem 0.9rem; border-radius: 4px;
    cursor: pointer; font-size: 0.85rem;
}
button.download:hover { background: #1e5030; }
button.download:disabled { opacity: 0.6; cursor: not-allowed; }
.empty { text-align: center; padding: 3rem; color: #888; }
.progress {
    font-size: 0.85rem; color: #036;
    min-width: 140px; display: inline-block; text-align: right;
}

.scans-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: start;
}
.scans-layout .card { margin-bottom: 0; }
.scans-layout .scans-list { grid-column: 1; grid-row: 1; }
.scans-layout .scans-detail { grid-column: 2; grid-row: 1; }

img.thumbnail {
    display: block;
    max-width: 100%;
    height: auto;
    margin-bottom: 1rem;
    border-radius: 4px;
    border: 1px solid #ddd;
    background: #f5f5f5;
}
dl.metadata { margin: 0; }
dl.metadata dt {
    font-size: 0.8rem; color: #666; text-transform: uppercase;
    margin-top: 1rem; letter-spacing: 0.03em;
}
dl.metadata dt:first-child { margin-top: 0; }
dl.metadata dd {
    margin: 0.2rem 0 0 0; font-size: 1rem; color: #222;
    word-break: break-word;
}
dl.metadata dd.mono {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 0.9rem; background: #f5f5f5;
    padding: 0.4rem 0.6rem; border-radius: 4px;
}

@media (max-width: 700px) {
    .scans-layout { grid-template-columns: 1fr; }
    .scans-layout .scans-list,
    .scans-layout .scans-detail { grid-column: 1; grid-row: auto; }
}

.live-layout {
    max-width: 1200px;
    margin: 2rem auto 0;
    padding: 0 1rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: start;
}
.live-layout .card { margin-bottom: 0; }
.live-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.live-frame img {
    display: none;
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.live-placeholder { color: #888; font-size: 0.9rem; }
.live-status {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 0.8rem;
    color: #555;
}
.live-status::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #888;
}
.live-status.live::before { background: #2a6e3f; }
.live-status.stale::before { background: #c97a00; }
.control-panel {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.ctl-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 0 0 auto;
}
.ctl-col .ctl { flex: 1; }
.control-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    align-content: start;
}
button.ctl {
    background: #fff;
    color: #1a1a2e;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 0.6rem 0.4rem;
    font-size: 0.9rem;
    cursor: pointer;
}
button.ctl:hover { background: #f0f0f0; }
button.ctl.span3 { grid-column: 1 / -1; }
#ctl-objectives {
    grid-column: 1 / -1;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 8px;
}
button.ctl.scan { border-color: #2a6e3f; color: #2a6e3f; }
.ctl-note {
    margin-top: 0.8rem;
    padding: 0.5rem 0.8rem;
    background: #e6f3ff;
    color: #036;
    border-radius: 4px;
    font-size: 0.85rem;
    text-align: center;
}

@media (max-width: 700px) {
    .live-layout { grid-template-columns: 1fr; }
}

.hidden { display: none; }
