:root {
    --bg: #f4f5f7;
    --panel: #fff;
    --border: #dfe3e8;
    --text: #1c2330;
    --muted: #6b7484;
    --accent: #2d6cdf;
    --ok: #1f9254;
    --warn: #b7791f;
    --err: #c0392b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 0 20px;
    background: #1c2330;
    color: #fff;
}

.topbar .brand { font-weight: 600; padding: 14px 0; }
.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topbar a {
    color: #c6ccd8;
    text-decoration: none;
    padding: 14px 12px;
}
.topbar a:hover { color: #fff; }
.topbar a.active { color: #fff; box-shadow: inset 0 -3px 0 var(--accent); }
.topbar .logout { color: #96a0b1; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }

h1 { font-size: 22px; margin: 0 0 20px; }
h2 { font-size: 17px; margin: 28px 0 12px; }

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 20px;
}

table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }

label { display: block; margin-bottom: 14px; font-size: 14px; }
label > span { display: block; margin-bottom: 4px; color: var(--muted); }

input[type=text], input[type=password], input[type=datetime-local], input[type=time], select, textarea {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    background: #fff;
}

textarea { min-height: 160px; resize: vertical; font-family: inherit; }

.btn {
    display: inline-block;
    padding: 9px 16px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--err); border-color: var(--err); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 180px; }
.row > .row-fixed { flex: 0 0 auto; min-width: 0; }

.flash { padding: 11px 14px; border-radius: 6px; margin-bottom: 16px; }
.flash-ok   { background: #e6f4ec; color: var(--ok); }
.flash-err  { background: #fbeae8; color: var(--err); }
.flash-warn { background: #fdf3e2; color: var(--warn); }

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 12px;
    background: #eceff3;
    color: var(--muted);
}
.badge-ok        { background: #e6f4ec; color: var(--ok); }
.badge-err       { background: #fbeae8; color: var(--err); }
.badge-warn      { background: #fdf3e2; color: var(--warn); }
.badge-scheduled { background: #e8effc; color: var(--accent); }

.muted { color: var(--muted); font-size: 13px; }

/* Drive browser + media grid */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.media-item {
    position: relative;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    background: #e8eaee;
    cursor: pointer;
    aspect-ratio: 1;
}
.media-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-item.selected { border-color: var(--accent); }
.media-item .pick-num {
    position: absolute;
    top: 6px; left: 6px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    width: 24px; height: 24px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}
.media-item.selected .pick-num { display: flex; }
.media-item .name {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,.6);
    color: #fff;
    font-size: 11px;
    padding: 3px 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Занятые кадры: уже опубликованные или обещанные другому посту.
   Кликом их не выбрать, поэтому и выглядеть они должны недоступными */
.media-item.is-blocked { cursor: not-allowed; }
.media-item.is-blocked img { filter: grayscale(1); opacity: .45; }
.media-item.is-blocked .name { background: rgba(0,0,0,.45); }

.media-item .blocked-tag {
    position: absolute;
    top: 6px; left: 6px; right: 6px;
    border-radius: 4px;
    padding: 2px 5px;
    font-size: 10px;
    font-weight: 600;
    text-align: center;
    color: #fff;
    background: rgba(0,0,0,.6);
}
.media-item.is-published .blocked-tag { background: rgba(176, 58, 46, .85); }
.media-item.is-reserved  .blocked-tag { background: rgba(191, 121, 15, .85); }

.media-item.shake { animation: shake .35s; }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-4px); }
    75%      { transform: translateX(4px); }
}

/* selected/ordered strip */
.order-strip { display: flex; gap: 8px; flex-wrap: wrap; min-height: 96px; }
.order-strip .order-item {
    position: relative;
    width: 90px; height: 90px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #e8eaee;
    cursor: grab;
}
.order-strip .order-item img { width: 100%; height: 100%; object-fit: cover; }
.order-strip .order-item.dragging { opacity: .4; }
.order-strip .order-item .remove,
.order-strip .order-item .swap {
    position: absolute; top: 2px;
    background: rgba(0,0,0,.65); color: #fff;
    border: none; border-radius: 50%;
    width: 20px; height: 20px; line-height: 1;
    cursor: pointer; font-size: 13px;
}
.order-strip .order-item .remove { right: 2px; }
.order-strip .order-item .swap   { right: 26px; font-size: 12px; }
.order-strip .order-item .remove:hover,
.order-strip .order-item .swap:hover { background: rgba(0,0,0,.85); }

.folder-list { list-style: none; padding: 0; margin: 0; }
.folder-list li { border-bottom: 1px solid var(--border); }
.folder-list a { display: block; padding: 9px 4px; text-decoration: none; color: var(--text); }
.folder-list a:hover { background: #f7f8fa; }

.breadcrumbs { font-size: 14px; margin-bottom: 12px; color: var(--muted); }
.breadcrumbs a { color: var(--accent); text-decoration: none; }

.login-box { max-width: 380px; margin: 90px auto; }

.spinner { display: inline-block; color: var(--muted); font-size: 13px; }
