:root {
    --bg: #ffffff;
    --surface: #ffffff;
    --soft: #f3f3f3;
    --soft-2: #eeeeee;
    --line: #d8d8d8;
    --line-soft: #ececec;
    --text: #3c4650;
    --muted: #7b8792;
    --green: #06b96f;
    --green-dark: #04965b;
    --orange: #f08300;
    --red: #ff1f2d;
    --blue: #3b82f6;
    --yellow-row: #fffec7;
    --radius: 4px;
    font-family: Inter, Arial, Helvetica, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

button,
input,
select,
textarea {
    font: inherit;
}

.hidden {
    display: none !important;
}

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

.danger {
    color: var(--red) !important;
}

.login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: #f7f7f7;
}

.login-panel {
    width: 380px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .08);
}

.login-panel h1 {
    margin: 0 0 8px;
    font-size: 24px;
}

.login-panel p {
    margin: 0 0 18px;
    color: var(--muted);
}

.app-shell {
    min-height: 100vh;
    display: block;
}

.side-nav {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: 180px;
    height: 100vh;
    overflow: auto;
    border-right: 1px solid var(--line-soft);
    background: #fff;
    padding-top: 21px;
}

.side-logo {
    width: 31px;
    height: 31px;
    margin: 0 auto 25px;
    display: grid;
    place-items: center;
    color: #119bd7;
    font-size: 24px;
    font-weight: 800;
    line-height: 1;
}

.side-nav nav {
    display: grid;
    gap: 7px;
}

.side-nav button {
    height: 41px;
    width: 100%;
    border: 0;
    background: transparent;
    color: #253440;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 17px;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
}

.side-nav button svg {
    width: 22px;
    height: 22px;
    stroke-width: 2.4;
    color: #3f444a;
    flex: 0 0 auto;
}

.side-nav button:hover {
    background: #f2f5f7;
}

.side-nav button.active {
    background: #223844;
    color: #fff;
    border-radius: 7px 0 0 7px;
    margin-left: 4px;
    width: calc(100% - 4px);
}

.side-nav button.active svg {
    color: #fff;
}

.main-area {
    min-width: 0;
    margin-left: 180px;
}

.app-header {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) auto;
    align-items: center;
    gap: 20px;
    padding: 14px 28px 10px;
    border-bottom: 1px solid var(--line-soft);
}

.app-header h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
}

.app-header p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.user-box {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    white-space: nowrap;
}

.workspace {
    padding: 16px 22px 26px;
}

.tab-panel {
    min-width: 1120px;
}

.page-tools,
.filter-row,
.action-bar,
.pager,
.radio-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.page-tools {
    margin-bottom: 14px;
}

.filter-row {
    margin: 8px 0 24px;
}

.pager {
    margin-top: 14px;
    gap: 34px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 29px;
    padding: 6px 13px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
    color: #3f4852;
    cursor: pointer;
    line-height: 1;
}

.btn svg {
    width: 15px;
    height: 15px;
}

.btn-sm {
    min-height: 27px;
    padding: 5px 10px;
    font-size: 12px;
}

.btn-xs {
    min-height: 25px;
    padding: 4px 8px;
    font-size: 12px;
    margin-right: 4px;
}

.btn-white {
    background: var(--surface);
}

.btn-white:hover {
    background: #f8f8f8;
}

.btn-green {
    background: var(--green);
    border-color: var(--green);
    color: white;
    font-weight: 600;
}

.btn-green:hover {
    background: var(--green-dark);
}

.btn-orange {
    background: var(--orange);
    border-color: var(--orange);
    color: white;
    font-weight: 600;
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

input,
select,
textarea {
    border: 1px solid #cfd4d9;
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius);
    min-height: 30px;
    padding: 6px 9px;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #93b8ff;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, .12);
}

textarea {
    width: 100%;
    resize: vertical;
    line-height: 1.45;
}

select {
    min-width: 150px;
}

.search-input {
    width: 292px;
}

.search-textarea {
    height: 30px;
    min-height: 30px;
    line-height: 16px;
    overflow: hidden;
    resize: none;
    white-space: nowrap;
}

.date-filter {
    width: 142px;
}

.caption-source-field {
    display: grid;
    gap: 6px;
    align-content: start;
    color: #4f5963;
    margin-bottom: 12px;
}

.caption-source-head {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 18px;
    line-height: 18px;
    color: #4f5963;
}

.caption-source-head span {
    font-weight: 400;
}

.caption-source-head .checkbox-label {
    min-height: 18px;
    height: 18px;
    line-height: 18px;
    margin: 0;
    color: var(--text);
    font-weight: 400;
}

.caption-source-head input {
    margin: 0;
}

#jobCaptionLibraryWrap {
    width: 100%;
}

.column-menu {
    position: relative;
}

.column-panel {
    position: absolute;
    top: 42px;
    right: 12px;
    z-index: 30;
    width: 230px;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .12);
}

.column-option {
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 7px 6px;
    color: #3f4852;
}

.column-option input {
    min-height: 0;
    width: 14px;
    height: 14px;
    padding: 0;
}

.column-hint {
    color: var(--muted);
    font-size: 12px;
    padding: 7px 6px;
}

.column-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line-soft);
    margin-top: 6px;
}

label {
    display: grid;
    gap: 6px;
    color: #4f5963;
    margin-bottom: 12px;
}

.inline-form {
    margin: 8px 0 16px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fbfbfb;
}

.inline-form textarea {
    margin-bottom: 8px;
}

.log {
    margin: 10px 0 0;
    background: #f6f8fa;
    border: 1px solid var(--line);
    color: #506070;
    padding: 10px;
    white-space: pre-wrap;
    max-height: 170px;
    overflow: auto;
}

.action-bar {
    background: var(--soft-2);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 18px;
    min-height: 44px;
}

.bar-close {
    border: 0;
    background: transparent;
    color: #2f3a44;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

.bar-close svg {
    width: 18px;
    height: 18px;
}

.action-bar strong {
    font-weight: 500;
}

.table-card {
    position: relative;
    border-radius: var(--radius);
    overflow: auto;
    max-height: calc(100vh - 250px);
    background: var(--surface);
}

.data-table {
    width: 100%;
    min-width: 1220px;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th,
.data-table td {
    border-bottom: 1px solid var(--line-soft);
    padding: 13px 12px;
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

.data-table th {
    position: sticky;
    top: 0;
    z-index: 6;
    background: var(--soft-2);
    color: #565d64;
    font-weight: 700;
}

.sort-head {
    width: 100%;
    border: 0;
    background: transparent;
    color: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0;
    font-weight: 700;
    cursor: pointer;
    text-align: left;
}

.data-table th.column-tools-head {
    right: 0;
    width: 48px;
    text-align: center;
}

.data-table td {
    height: 58px;
}

.data-table tr:hover td {
    background: #fafafa;
}

.data-table tr.selected td {
    background: var(--yellow-row);
}

.data-table .sticky-col {
    position: sticky;
    background: #fff;
    z-index: 4;
}

.data-table th.sticky-col {
    z-index: 8;
    background: var(--soft-2);
}

.data-table tr:hover .sticky-col {
    background: #fafafa;
}

.data-table tr.selected .sticky-col {
    background: var(--yellow-row);
}

.data-table [data-select-row] {
    cursor: default;
    user-select: none;
}

.sticky-check {
    left: 0;
    width: 44px;
    min-width: 44px;
    max-width: 44px;
    text-align: center !important;
}

.sticky-page-name {
    left: 44px;
    width: 260px;
    min-width: 260px;
    max-width: 260px;
}

.sticky-page-id {
    left: 304px;
    width: 175px;
    min-width: 175px;
    max-width: 175px;
}

.sticky-page-id-first {
    left: 44px;
    width: 175px;
    min-width: 175px;
    max-width: 175px;
}

.col-insightsMediaView,
.col-insightsEngagements,
.col-insightsFollowsNet,
.col-insightsFollowsTotal,
.col-insightsReactions,
.col-insightsComments,
.col-insightsShares,
.col-insightsPostCount,
.col-insightsViewers,
.col-insightsViews {
    min-width: 150px;
}

.data-table input[type="checkbox"] {
    min-height: 0;
    width: 15px;
    height: 15px;
    padding: 0;
}

code {
    font-family: Consolas, Monaco, monospace;
    color: #374151;
}

.cell-input {
    min-width: 190px;
    max-width: 260px;
    height: 29px;
}

.icon-btn {
    width: 28px;
    height: 28px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: #3f4852;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    vertical-align: middle;
}

.icon-btn:hover {
    background: #f2f5f7;
    border-color: var(--line);
}

.icon-btn svg {
    width: 15px;
    height: 15px;
}

.note-edit {
    margin-right: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .12s ease;
}

.data-table tr:hover .note-edit {
    opacity: 1;
    pointer-events: auto;
}

.note-preview {
    display: inline-block;
    max-width: 230px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.state {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.state i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.state.ok i {
    background: #008a12;
}

.state.warn i {
    background: #d99000;
}

.state.bad i {
    background: var(--red);
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--tag, #9ca3af) 35%, #d1d5db);
    background: color-mix(in srgb, var(--tag, #9ca3af) 12%, #fff);
}

.dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 8px;
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 26px !important;
}

.stats-strip {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    margin-bottom: 18px;
}

.stat-cell {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    background: #fafafa;
}

.stat-cell span {
    display: block;
    color: var(--muted);
    margin-bottom: 8px;
}

.stat-cell strong {
    font-size: 24px;
}

.split-layout {
    display: grid;
    grid-template-columns: 360px minmax(760px, 1fr);
    gap: 18px;
    align-items: start;
}

.form-panel {
    border: 1px solid var(--line);
    background: #fafafa;
    border-radius: var(--radius);
    padding: 16px;
}

.form-panel h2 {
    margin: 0 0 16px;
    font-size: 18px;
}

.form-panel input,
.form-panel select,
.form-panel textarea {
    width: 100%;
}

.radio-row label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 12px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    gap: 14px;
    max-width: 980px;
}

.settings-grid > label {
    line-height: 18px;
}

.settings-grid .full {
    grid-column: 1 / -1;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-label input {
    width: 15px;
    min-height: 0;
}

.wide-modal {
    width: min(820px, calc(100vw - 32px));
}

.modal-panel.random-video-panel {
    width: min(900px, calc(100vw - 32px));
    max-width: 900px;
}

.modal-panel.sequence-video-panel {
    width: min(1100px, calc(100vw - 32px));
    max-width: 1100px;
}

.page-group-manager-panel {
    width: min(780px, calc(100vw - 32px));
}

.group-manager-form {
    grid-template-columns: 1fr 64px auto auto;
    display: grid;
    gap: 8px;
    align-items: center;
}

.compact-table-card {
    max-height: min(58vh, 520px);
    overflow: auto;
}

.modal-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.modal-tabs .btn.active {
    border-color: var(--green);
    color: var(--green);
    font-weight: 600;
}

.comment-setup-panel.disabled {
    opacity: .5;
    pointer-events: none;
}

.comment-toolbar {
    display: grid;
    grid-template-columns: 240px 220px max-content;
    gap: 10px;
    align-items: end;
    justify-content: start;
    margin-bottom: 12px;
}

.comment-toolbar label {
    margin-bottom: 0;
}

.comment-toolbar .btn {
    align-self: end;
    min-width: 150px;
    min-height: 30px;
    height: 30px;
    padding-top: 6px;
    padding-bottom: 6px;
}

.comment-rows {
    display: grid;
    gap: 10px;
    max-height: min(48vh, 520px);
    overflow: auto;
    padding-right: 4px;
}

.comment-row {
    display: grid;
    grid-template-columns: 28px 300px 150px 34px;
    gap: 10px;
    align-items: start;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
}

.comment-row.random-mode {
    grid-template-columns: 300px 150px 34px;
}

.comment-select-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 34px;
}

.comment-row textarea {
    width: 300px;
    height: 150px;
    resize: vertical;
    min-height: 150px;
}

.comment-row.random-mode textarea {
    grid-column: 1;
}

.comment-row.random-mode .comment-image-wrap {
    grid-column: 2;
}

.comment-row.random-mode .comment-row-actions {
    grid-column: 3;
}

.comment-image-box {
    width: 150px;
    height: 150px;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    overflow: hidden;
    background: #fafafa;
    position: relative;
}

.comment-image-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.comment-image-box .btn {
    min-width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
}

.comment-row-actions {
    display: grid;
    gap: 6px;
    justify-items: center;
}

.sequence-page-card {
    max-height: min(62vh, 620px);
    overflow: auto;
}

.sequence-page-table {
    min-width: 980px;
}

.sequence-page-table th:nth-child(1),
.sequence-page-table td:nth-child(1) {
    width: 240px;
}

.sequence-page-table th:nth-child(2),
.sequence-page-table td:nth-child(2) {
    width: 180px;
}

.sequence-page-table tr.invalid {
    background: #fff1f2;
}

.sequence-page-table .path-picker {
    min-width: 420px;
}

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

.validation-state.error {
    color: var(--red);
    font-weight: 600;
}

.validation-state.ok {
    color: var(--green);
    font-weight: 600;
}

.xwide-modal {
    width: calc(100vw - 8px);
    height: calc(100vh - 8px);
    max-height: calc(100vh - 8px);
    overflow-y: auto;
    overflow-x: hidden;
}

.path-picker {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.path-picker input {
    width: 100%;
}

.path-picker input,
.path-picker .btn,
#jobCaptionLibraryWrap {
    min-height: 30px;
}

.jobs-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.jobs-table {
    min-width: 900px;
}

.jobs-table th:nth-child(2),
.jobs-table td:nth-child(2) {
    width: 260px;
    max-width: 260px;
}

.jobs-table th:nth-child(3),
.jobs-table td:nth-child(3) {
    width: 150px;
    max-width: 150px;
}

.jobs-table th:nth-child(6),
.jobs-table td:nth-child(6) {
    width: 88px;
    text-align: center;
}

.jobs-table th:nth-child(4),
.jobs-table td:nth-child(4) {
    width: 120px;
}

.jobs-table th:nth-child(5),
.jobs-table td:nth-child(5) {
    width: 130px;
}

.job-name-cell,
.job-groups-cell {
    overflow: hidden;
    text-overflow: ellipsis;
}

.job-actions {
    display: flex;
    gap: 4px;
}

.job-logs-table {
    min-width: 1080px;
}

.job-log-time {
    width: 150px;
    max-width: 150px;
    white-space: normal;
}

.job-logs-table th:first-child,
.job-logs-table td:first-child {
    width: 150px;
    max-width: 150px;
}

.job-logs-table th:nth-child(2),
.job-logs-table td:nth-child(2) {
    width: 80px;
    max-width: 80px;
}

.link-btn {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--green-dark);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.link-btn:hover {
    text-decoration: underline;
}

.round-progress-head {
    display: grid;
    grid-template-columns: minmax(140px, auto) minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.round-filter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: max-content;
    font-size: 13px;
    color: var(--muted);
}

.round-filter input {
    width: 78px;
}

.round-summary {
    justify-self: end;
    display: inline-flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    width: max-content;
    max-width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fafafa;
    text-align: right;
    white-space: nowrap;
}

#roundProgressContent {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
}

.round-progress-scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.round-progress-table {
    min-width: 760px;
}

.round-progress-table th:nth-child(1),
.round-progress-table td:nth-child(1),
.round-progress-table th:nth-child(5),
.round-progress-table td:nth-child(5) {
    width: 92px;
    text-align: center;
}

.confirm-panel {
    max-width: 420px;
}

.confirm-panel p {
    margin: 8px 0 18px;
    color: var(--text);
}

.job-log-error {
    color: var(--red);
    font-weight: 600;
}

.job-log-error td {
    background: #fff1f2;
}

.compact-field input {
    max-width: 120px;
}

.job-detail-content h3 {
    margin: 14px 0 8px;
    font-size: 14px;
}

.job-detail-grid {
    display: grid;
    grid-template-columns: minmax(260px, .75fr) minmax(420px, 1fr);
    gap: 16px;
}

.job-edit-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr)) auto;
    gap: 10px;
    align-items: end;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fafafa;
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
}

.detail-table th,
.detail-table td {
    border-bottom: 1px solid var(--line-soft);
    padding: 8px;
    text-align: left;
    vertical-align: top;
}

.detail-table th {
    width: 130px;
    color: var(--muted);
    font-weight: 600;
}

.detail-scroll {
    max-height: 42vh;
    overflow-x: hidden;
}

.compact-table {
    min-width: 0;
    width: 100%;
    table-layout: fixed;
}

.compact-table th,
.compact-table td {
    white-space: normal;
    overflow-wrap: anywhere;
}

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 100;
    background: #323b44;
    color: white;
    border-radius: var(--radius);
    padding: 11px 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
}

.toast.error {
    background: var(--red);
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, .28);
}

.modal-panel {
    width: 500px;
    background: #fff;
    border-radius: 6px;
    border: 1px solid var(--line);
    box-shadow: 0 18px 48px rgba(0, 0, 0, .18);
    padding: 18px;
}

#randomVideoForm.modal-panel {
    width: min(900px, calc(100vw - 32px));
    max-width: 900px;
}

.modal-panel.xwide-modal {
    display: flex;
    flex-direction: column;
    width: 1500px;
    max-width: none;
    height: calc(100vh - 50px);
    max-height: calc(100vh - 8px);
}

.via-batch-panel {
    width: min(600px, calc(100vw - 32px));
}

.via-add-panel {
    width: min(720px, calc(100vw - 32px));
}

.via-batch-panel textarea,
.via-batch-panel select,
.via-batch-panel input,
.via-add-panel textarea {
    width: 100%;
}

.modal-head,
.modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.modal-head {
    margin-bottom: 16px;
}

.modal-head h2 {
    margin: 0;
    font-size: 18px;
}


.modal-actions {
    justify-content: flex-end;
    margin-top: 16px;
}

@media (max-width: 1200px) {
    .side-nav {
        width: 72px;
    }

    .main-area {
        margin-left: 72px;
    }

    .side-nav button {
        justify-content: center;
        padding: 0;
    }

    .side-nav button span,
    .side-nav button {
        font-size: 0;
    }

    .side-nav button svg {
        width: 30px;
        height: 30px;
    }

    .app-header {
        grid-template-columns: 1fr;
    }

    .user-box {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .tab-panel {
        min-width: 0;
    }

    .split-layout {
        grid-template-columns: 1fr;
    }

    .stats-strip {
        grid-template-columns: repeat(2, 1fr);
    }
}
