:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f4f7fb;
  line-height: 1.5;
}
* { box-sizing: border-box; }
body { margin: 0; }
.topbar { display: none; }
.dashboard-shell { min-height: 100vh; display: flex; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 230px; display: flex; flex-direction: column; background: #172033; color: #fff; padding: 22px 14px; }
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 0 10px 22px; border-bottom: 1px solid #334155; }
.sidebar-brand span { font-size: 12px; color: #bfdbfe; }
.sidebar-nav { display: flex; flex-direction: column; gap: 5px; padding-top: 18px; }
.sidebar-link, .sidebar-group-title { display: block; color: #cbd5e1; border-left: 3px solid transparent; border-radius: 4px; padding: 11px 12px; }
.sidebar-link { text-decoration: none; }
.sidebar-link:hover, .sidebar-link.active { color: #fff; background: #26364d; border-left-color: #60a5fa; }
.sidebar-group { margin-top: 3px; }
.sidebar-group-title { color: #fff; font-weight: 600; padding-bottom: 7px; }
.sidebar-subnav { display: flex; flex-direction: column; gap: 2px; margin-left: 11px; padding-left: 10px; border-left: 1px solid #475569; }
.sidebar-sub-link { display: block; color: #cbd5e1; text-decoration: none; border-radius: 4px; padding: 8px 10px; }
.sidebar-sub-link:hover, .sidebar-sub-link.active { color: #fff; background: #26364d; }
.sidebar-footer { display: flex; flex-direction: column; gap: 12px; margin-top: auto; padding: 14px 10px 0; border-top: 1px solid #334155; }
.sidebar-footer .muted { color: #cbd5e1; font-size: 13px; }
.sidebar-footer button { width: 100%; }
.content-area { width: calc(100% - 230px); margin-left: 230px; padding: 28px; max-width: calc(100% - 230px); }
.content-panel[hidden], .dedup-field[hidden], .bulk-rule-form[hidden], .bulk-dedup-field[hidden], .scope-empty[hidden], [data-bulk-selection][hidden], .scope-account[hidden] { display: none !important; }
.content-panel { display: block; }
.section-block { background: #fff; border: 1px solid #e0e6ef; border-radius: 8px; padding: 20px; margin-bottom: 18px; }
.auth-card { max-width: 440px; margin: 10vh auto; padding: 28px; background: #fff; border: 1px solid #e0e6ef; border-radius: 8px; box-shadow: 0 8px 30px #1d35571a; }
.version { display: inline-block; margin-left: 10px; padding: 2px 7px; border: 1px solid #64748b; border-radius: 4px; color: #dbeafe; font-size: 12px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; }
.section-block h2 { margin: 0 0 14px; font-size: 20px; border-bottom: 1px solid #e6ebf2; padding-bottom: 10px; }
.section-heading h2 { margin-bottom: 3px; }
.section-heading p { margin-top: 0; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 14px; }
input, select, button { font: inherit; border-radius: 6px; border: 1px solid #cbd5e1; padding: 8px 10px; background: #fff; }
/* Lucide chevron-down, embedded so native arrows have consistent inset spacing. */
select { appearance: none; -webkit-appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
input:focus, select:focus { outline: 2px solid #93c5fd; border-color: #3b82f6; }
.secret-input { -webkit-text-security: disc; }
button { cursor: pointer; color: #fff; background: #2563eb; border-color: #2563eb; }
button.secondary { background: #475569; border-color: #475569; }
button.danger { background: #dc2626; border-color: #dc2626; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
form { margin: 0; }
.keyword-form { display: block; margin-bottom: 16px; }
.keyword-form > label { display: block; margin-bottom: 14px; max-width: 620px; }
.keyword-form > label:not(.check) input, .keyword-form > label:not(.check) select { display: block; width: 100%; margin-top: 6px; }
.keyword-form .check { display: inline-block; vertical-align: middle; min-height: 0; margin: 0 22px 12px 0; }
.keyword-form > .check input, .keyword-form fieldset .check input { display: inline-block; width: auto; margin: 0 7px 0 0; vertical-align: middle; }
.keyword-form fieldset { display: block; margin: 8px 0 16px; max-width: 100%; }
.keyword-form fieldset .check { margin-bottom: 8px; }
.keyword-form button { margin-top: 2px; }
.keyword-actions { display: block; }
.keyword-actions button { margin-right: 8px; }
.keyword-bulk-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.data-table .rule-select-cell { width: 42px; text-align: center; vertical-align: middle; }
.rule-select-cell input { width: 16px; height: 16px; margin: 0; vertical-align: middle; accent-color: #2563eb; }
.keyword-edit-form { padding: 14px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; }
.bulk-rule-form { margin: 18px 0; padding: 14px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; }
.bulk-rule-form h3 { margin: 0 0 4px; font-size: 16px; }
.bulk-rule-form > .check { display: flex; flex-direction: row; align-items: center; gap: 7px; min-height: 40px; margin: 8px 18px 8px 0; }
.bulk-rule-form > select { width: 190px; max-width: 100%; min-width: 0; margin-right: 18px; }
.bulk-rule-form fieldset { display: block; margin: 8px 0 12px; }
.bulk-rule-form fieldset .check { display: flex; flex-direction: row; align-items: center; gap: 7px; min-height: 40px; margin: 0 22px 8px 0; }
.bulk-rule-form .bulk-dedup-field { display: block; margin: 0 18px 12px 0; max-width: 220px; }
.bulk-rule-form .bulk-dedup-field input { display: block; width: 100%; margin-top: 6px; }
.scope-account { margin-top: 14px; }
 .data-table th, .data-table td { padding: 9px; border: 1px solid #dbe3ee; vertical-align: middle; }
 .data-table th { background: #f8fafc; white-space: nowrap; }
.data-table .id-cell { width: 52px; text-align: center; }
.data-table td.id-cell { color: #64748b; font-weight: 600; }
.data-table td:not(.actions):not(.account-label-cell) { overflow-wrap: anywhere; }
.data-table th:last-child { width: 100px; }
.account-table th:last-child { width: 144px; }
.form-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; margin-bottom: 16px; }
.form-fields > label { flex: 1 1 220px; min-width: 190px; }
.form-fields .full { flex-basis: 100%; width: 100%; }
.inline-form { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.inline-form input, .inline-form select { flex: 1; min-width: 150px; }
.account-verify-form { align-items: flex-end; }
.account-verify-form select { min-width: 190px; }
.check { display: flex; flex-direction: row; align-items: center; gap: 7px; min-height: 40px; }
.check input { width: auto; margin: 0; }
fieldset { border: 1px solid #dbe3ee; border-radius: 6px; padding: 12px; display: flex; flex-wrap: wrap; gap: 12px; }
legend { font-weight: 600; padding: 0 5px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; min-width: 760px; }
th, td { text-align: left; border-bottom: 1px solid #e8edf3; padding: 9px; vertical-align: top; }
td form { display: inline-block; margin: 2px 4px 2px 0; }
code { white-space: pre-wrap; word-break: break-word; }
.muted { color: #64748b; }
.alert { padding: 10px 12px; background: #dcfce7; border: 1px solid #86efac; color: #166534; border-radius: 6px; margin-bottom: 16px; }
.alert.error { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.actions { white-space: nowrap; }
.actions form { vertical-align: middle; }
.actions > .action-icon { margin-right: 4px; }
.action-icon { display: inline-block; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 4px; background: transparent; vertical-align: middle; line-height: 32px; text-align: center; }
.action-icon svg { width: 18px; height: 18px; vertical-align: middle; }
.action-icon:hover { background: #f1f5f9; }
.action-icon:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.action-edit { color: #172033; }
.action-pause { color: #df8100; }
.action-play { color: #009d75; }
.action-delete { color: #ff2638; }
.action-refresh { color: #4285ff; }
.action-pause svg, .action-play svg { fill: currentColor; }
.action-delete:hover { background: #fff0f1; }
.compact-form { margin: 2px 0; }
.error-text { color: #b91c1c; }
.scope-mode-form { display: block; margin: 0; white-space: nowrap; }
.scope-mode-form select { width: auto; min-width: 0; vertical-align: middle; }
.account-table { min-width: 1050px; }
.account-phone { white-space: nowrap; }
.account-label-cell { width: 180px; min-width: 140px; }
.account-label-display { display: inline-block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.account-cache-cell { min-width: 65px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.scope-toolbar { display: flex; align-items: flex-end; gap: 12px; margin: 0 0 14px; }
.scope-toolbar > label { flex: 0 1 220px; min-width: 0; margin: 0; }
.scope-toolbar select { display: block; width: 100%; height: 40px; margin-top: 0; }
.scope-toolbar .action-add { flex-shrink: 0; }
.settings-fields > label { min-width: 0; }
.settings-fields input:not([type="checkbox"]) { width: 100%; min-width: 0; }
#panel-settings .version { color: #475569; border-color: #cbd5e1; }
.backup-settings .check { flex-direction: row; align-items: center; }
.backup-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.backup-upload { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; max-width: 100%; }
.backup-upload input[type="file"] { width: 300px; max-width: 100%; min-width: 0; }
.backup-table { min-width: 700px; }
.backup-name { overflow-wrap: anywhere; }
.button-link { display: inline-block; text-decoration: none; color: #fff; padding: 8px 10px; border: 1px solid #475569; border-radius: 6px; background: #475569; vertical-align: middle; }
.backup-table .button-link { margin-right: 5px; }
.backup-warning { font-size: 14px; color: #b91c1c; overflow-wrap: anywhere; }
.app-dialog { width: 440px; max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; margin: auto; padding: 24px; border: 1px solid #dbe3ee; border-radius: 8px; color: #172033; background: #fff; box-shadow: 0 16px 48px #0003; }
.app-dialog::backdrop { background: #0006; }
.account-edit-dialog { width: 700px; padding: 24px; border-radius: 16px; }
.account-edit-fields { display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: center; column-gap: 16px; row-gap: 16px; margin-bottom: 26px; }
.account-edit-fields label { color: #172033; font-weight: 400; font-size: 14px; }
.account-edit-fields input { width: 100%; min-width: 0; height: 48px; padding: 10px 15px; border: 1px solid #dce2eb; border-radius: 19px; background: #fff; font-size: 14px; color: #172033; }
.account-edit-dialog .dialog-actions button { min-width: 0; padding: 9px 14px; border-radius: 6px; font-weight: 400; }
.account-edit-dialog .account-edit-save { color: #fff; background: #2563eb; border-color: #2563eb; }
.account-edit-dialog .account-edit-save:hover { background: #1d4ed8; }
#account-edit-status { margin: -10px 0 16px; }
#account-edit-status[hidden] { display: none; }
.app-dialog h2 { margin: 0 0 14px; font-size: 18px; }
.app-dialog p { margin: 0 0 22px; overflow-wrap: anywhere; }
.app-dialog select { width: 100%; min-width: 0; }
#webdav-import-status { margin-top: 10px; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.dialog-actions button { min-width: 76px; }
.save-status { position: fixed; top: 18px; right: 18px; z-index: 20; max-width: min(460px, calc(100vw - 36px)); padding: 10px 14px; border: 1px solid #86efac; border-radius: 6px; background: #dcfce7; color: #166534; box-shadow: 0 4px 16px #0002; overflow-wrap: anywhere; font-size: 14px; }
.save-status.error { border-color: #fca5a5; background: #fee2e2; color: #991b1b; }
.save-status.pending { border-color: #cbd5e1; background: #fff; color: #475569; }
.save-status[hidden] { display: none; }
@media (max-width: 800px) {
  .sidebar { width: 185px; padding: 16px 9px; }
  .content-area { width: calc(100% - 185px); margin-left: 185px; max-width: calc(100% - 185px); padding: 16px 10px; }
  .sidebar-brand { padding: 0 7px 16px; }
  .sidebar-link, .sidebar-group-title { padding: 10px 8px; font-size: 14px; }
  .sidebar-subnav { margin-left: 7px; padding-left: 7px; }
  .section-block { padding: 14px; }
  .form-fields > label { flex-basis: 100%; }
  .keyword-form > label { max-width: none; }
  .bulk-rule-form .bulk-dedup-field { display: block; margin-right: 0; }
}
@media (max-width: 560px) {
  .account-edit-dialog { padding: 20px 18px; }
  .account-edit-fields { column-gap: 14px; }
  .sidebar { width: 110px; padding: 14px 6px; }
  .sidebar-brand { flex-direction: column; align-items: flex-start; gap: 4px; padding: 0 4px 12px; }
  .sidebar-footer { padding: 12px 4px 0; }
  .sidebar-footer .muted { overflow-wrap: anywhere; }
  .content-area { width: calc(100% - 110px); max-width: calc(100% - 110px); margin-left: 110px; padding: 12px 8px; }
  .section-block { padding: 12px; }
  .backup-actions, .backup-upload { align-items: flex-start; }
  .backup-upload input[type="file"] { width: 100%; }
}

.action-add { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 40px; padding: 0; border: 1px solid #475569; border-radius: 8px; color: #172033; background: #f8fafc; vertical-align: middle; }
.action-add:hover { background: #e8edf3; }
.action-add svg { width: 18px; height: 18px; }
.editor-dialog { width: 700px; }
.editor-dialog .keyword-form, .editor-dialog .inline-form, .modal-form { display: flex; flex-wrap: wrap; gap: 14px; }
.editor-dialog form > label { min-width: 0; }
.editor-dialog .form-fields { width: 100%; }
.editor-dialog .form-fields > label { flex: 1 1 100%; }
.editor-dialog .dialog-actions { width: 100%; margin-top: 12px; }
.editor-dialog form { font-size: 14px; color: #172033; }
.editor-dialog .bulk-rule-form { padding: 0; margin: 0; border: 0; background: transparent; display: flex; flex-direction: column; gap: 12px; }
.editor-dialog .bulk-rule-form .bulk-dedup-field[hidden] { display: none; }
.editor-dialog .bulk-rule-form .bulk-dedup-field { display: block; }

.editor-dialog .keyword-form { display: block; }
.editor-dialog .inline-form > label { flex: 1 1 100%; }
.editor-dialog .inline-form > label input, .editor-dialog .inline-form > label select { width: 100%; min-width: 0; }
