
    :root { --bg:#f6f7f9; --card:#fff; --ink:#202124; --muted:#5f6368; --line:#dadce0; --blue:#1a73e8; --red:#b3261e; --green:#137333; --shadow:0 1px 2px rgba(60,64,67,.15); }
    * { box-sizing:border-box; }
    [hidden] { display:none !important; }
    body { margin:0; font:14px/1.45 system-ui,-apple-system,"Segoe UI",Arial,sans-serif; color:var(--ink); background:var(--bg); }
    button,input,select,textarea { font:inherit; }
    button { border:0; border-radius:8px; padding:9px 13px; cursor:pointer; background:#e8f0fe; color:#174ea6; font-weight:650; }
    button.primary { background:var(--blue); color:#fff; }
    button.ghost { background:transparent; color:var(--muted); }
    button.danger-button { background:#fce8e6; color:var(--red); }
    button:disabled { opacity:.5; cursor:not-allowed; }
    header { position:sticky; top:0; z-index:5; display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px max(16px,calc((100vw - 1280px)/2)); background:#fff; border-bottom:1px solid var(--line); }
    h1 { margin:0; font-size:20px; } h2 { margin:0 0 14px; font-size:17px; } h3 { margin:14px 0 8px; font-size:14px; }
    .user { text-align:right; color:var(--muted); font-size:12px; }
    main { max-width:1280px; margin:auto; padding:16px; }
    .toolbar,.alerts,.planning-stats,.metal-total { display:flex; gap:8px; flex-wrap:wrap; }
    .toolbar { margin-bottom:14px; }
    .card { background:var(--card); border:1px solid var(--line); border-radius:12px; box-shadow:var(--shadow); padding:16px; margin-bottom:16px; }
    .summary { display:grid; grid-template-columns:repeat(7,minmax(120px,1fr)); gap:8px; overflow:auto; }
    .day { min-width:120px; border:1px solid var(--line); border-radius:10px; padding:10px; }
    .day[role="button"] { cursor:pointer; }
    .day.selected { border-color:var(--blue); box-shadow:0 0 0 2px #d2e3fc inset; background:#f8fbff; }
    .day strong { display:block; margin-bottom:6px; }
    .count { display:flex; justify-content:space-between; color:var(--muted); font-size:12px; }
    .total { margin-top:6px; border-top:1px solid var(--line); padding-top:5px; font-weight:700; }
    .alerts { margin-bottom:12px; }
    .pill { border-radius:999px; padding:6px 10px; background:#f1f3f4; }
    button.pill { color:var(--ink); font-weight:600; }
    button.pill.selected { box-shadow:0 0 0 2px var(--blue) inset; }
    .danger { color:var(--red); background:#fce8e6; }
    .filters { display:grid; grid-template-columns:minmax(180px,2fr) repeat(3,minmax(135px,1fr)); gap:8px; margin-bottom:10px; }
    .filters.secondary { grid-template-columns:repeat(3,minmax(135px,1fr)); }
    input,select,textarea { width:100%; border:1px solid var(--line); border-radius:8px; padding:9px 10px; background:#fff; color:var(--ink); }
    textarea { resize:vertical; min-height:72px; }
    .orders { display:grid; gap:9px; }
    .order { display:grid; grid-template-columns:minmax(150px,1.1fr) minmax(125px,.8fr) minmax(155px,1fr) minmax(190px,1.35fr) minmax(175px,1.1fr); gap:10px; align-items:center; border:1px solid var(--line); border-radius:10px; padding:12px; }
    .order-title { font-size:16px; font-weight:750; }
    .title-row { display:flex; align-items:center; gap:7px; }
    .title-row .drawing-link { margin-left:auto; }
    .drawing-link { display:inline-flex; align-items:center; justify-content:center; min-height:32px; padding:6px 9px; border-radius:8px; background:#e8f0fe; color:#174ea6; font-weight:650; text-decoration:none; white-space:nowrap; }
    .select-order { width:auto; margin-right:2px; }
    .label { display:block; color:var(--muted); font-size:11px; margin:4px 0 2px; }
    .status[data-status="Новая"] { color:#7c4a03; background:#fef7e0; }
    .status[data-status="Передано в цех"] { color:#174ea6; background:#e8f0fe; }
    .status { display:inline-block; padding:4px 8px; border-radius:999px; background:#f1f3f4; }
    .status[data-status="Готово"] { color:var(--green); background:#e6f4ea; }
    .badge.size { color:#174ea6; background:#e8f0fe; }
    .comment-box { grid-column:1/-1; padding:9px 11px; border-left:4px solid #f9ab00; border-radius:7px; background:#fef7e0; }
    .comment-box .label { margin-top:0; color:#7c4a03; font-weight:700; }
    .comment-text { white-space:pre-wrap; overflow-wrap:anywhere; }
    .comment-text.clamped { display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:3; overflow:hidden; }
    .comment-toggle { padding:4px 0; margin-top:4px; background:transparent; color:#174ea6; }
    .primary-actions { justify-content:flex-start; }
    .status[data-status="Запланировано"] { color:#174ea6; background:#e8f0fe; }
    .badge { display:inline-block; margin:4px 4px 0 0; padding:3px 7px; border-radius:999px; font-size:11px; font-weight:750; background:#f1f3f4; }
    .badge.urgent { color:#fff; background:var(--red); }
    .badge.warning { color:#7c4a03; background:#fef7e0; }
    .badge.overdue { color:var(--red); background:#fce8e6; }
    .badge.archive { color:#fff; background:#5f6368; }
    .order.archived { background:#f8f9fa; border-style:dashed; }
    .actions { display:flex; flex-wrap:wrap; gap:5px; justify-content:flex-end; }
    .actions button { padding:7px 9px; }
    .order:has(.status[data-status="Готово"]) button[data-action="edit"] { display:none; }
    .tags { display:flex; gap:5px; flex-wrap:wrap; margin-top:4px; }
    .tag { padding:3px 7px; border-radius:999px; background:#f1f3f4; color:#3c4043; font-size:11px; font-weight:600; }
    button.tag:hover { background:#e8f0fe; color:#174ea6; }
    .empty { text-align:center; color:var(--muted); padding:24px; }
    dialog { border:0; border-radius:14px; width:min(620px,calc(100vw - 24px)); padding:0; box-shadow:0 16px 48px rgba(0,0,0,.25); }
    dialog.wide { width:min(980px,calc(100vw - 24px)); }
    dialog::backdrop { background:rgba(32,33,36,.45); }
    .modal { padding:20px; } .modal footer { display:flex; justify-content:flex-end; gap:8px; margin-top:16px; }
    .grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
    .field { margin-bottom:12px; } .field > label { display:block; font-weight:650; margin-bottom:5px; }
    .hint { color:var(--muted); font-size:12px; }
    .toast { position:fixed; right:16px; bottom:16px; max-width:360px; padding:12px 14px; border-radius:9px; color:#fff; background:#303134; box-shadow:0 4px 16px rgba(0,0,0,.25); z-index:10; }
    .toast.error { background:var(--red); }
    .loading { opacity:.6; pointer-events:none; }
    dialog.create-progress { position:fixed; inset:0; width:100vw; max-width:none; height:100vh; max-height:none; margin:0; border:0; border-radius:0; padding:16px; background:rgba(32,33,36,.58); place-items:center; }
    dialog.create-progress[open] { display:grid; }
    dialog.create-progress::backdrop { background:transparent; }
    .create-progress-card { width:min(420px,100%); padding:24px; border-radius:14px; background:#fff; box-shadow:0 16px 48px rgba(0,0,0,.3); text-align:center; }
    .create-progress-card h2 { margin-bottom:7px; }
    .create-progress-card p { margin:0; color:var(--muted); }
    .spinner { width:38px; height:38px; margin:0 auto 16px; border:4px solid #d2e3fc; border-top-color:var(--blue); border-radius:50%; animation:spin .8s linear infinite; }
    @keyframes spin { to { transform:rotate(360deg); } }
    .history { max-height:60vh; overflow:auto; display:grid; gap:8px; }
    .history-item { border-left:3px solid var(--line); padding:6px 10px; }
    .table-scroll { max-height:280px; overflow:auto; margin-bottom:12px; }
    .data-table { width:100%; border-collapse:collapse; font-size:12px; }
    .data-table th,.data-table td { border-bottom:1px solid var(--line); padding:7px 6px; text-align:left; white-space:nowrap; }
    .data-table th { color:var(--muted); position:sticky; top:0; background:#fff; }
    .metal-total { margin:10px 0; font-weight:700; }
    .checkline { display:flex; align-items:center; gap:6px; margin-top:6px; }
    .checkline input { width:auto; }
    .section-title { margin:16px 0 10px; font-weight:750; }
    .tabs { display:flex; gap:6px; overflow:auto; margin:0 0 12px; padding-bottom:2px; }
    .tab { white-space:nowrap; background:#f1f3f4; color:var(--muted); }
    .tab.active { background:var(--blue); color:#fff; }
    .batch-bar { display:flex; align-items:end; gap:10px; padding:10px; margin-bottom:10px; border:1px solid #aecbfa; border-radius:10px; background:#f8fbff; }
    .batch-bar .field { margin:0; min-width:180px; }
    .production-date { display:flex; align-items:center; gap:5px; }
    .production-date input { min-width:145px; cursor:pointer; color:#174ea6; font-weight:650; }
    .production-date button { flex:0 0 auto; padding:8px 10px; }
    .info-list { display:grid; gap:10px; margin:14px 0; }
    .info-list div { padding-bottom:8px; border-bottom:1px solid var(--line); }
    .writeoff-reversed { opacity:.65; text-decoration:line-through; }
    .writeoff-delete { min-width:32px; padding:6px 9px; border-radius:50%; background:#fce8e6; color:var(--red); font-size:18px; line-height:1; }
    .choice-list { display:flex; flex-wrap:wrap; gap:6px; padding:8px; border:1px solid var(--line); border-radius:8px; min-height:42px; }
    .choice { display:flex; align-items:center; gap:5px; background:#f8f9fa; border-radius:999px; padding:5px 8px; }
    .choice input { width:auto; }
    .draft-box { border:1px solid var(--line); border-radius:10px; padding:12px; margin-top:12px; }
    .advanced-filters { margin-bottom:10px; }
    .advanced-filters summary { cursor:pointer; color:#174ea6; font-weight:650; margin-bottom:8px; }
    .notification-error { white-space:normal !important; min-width:220px; max-width:440px; overflow-wrap:anywhere; }
    .file-list { display:grid; gap:8px; margin-top:10px; }
    .file-item { display:flex; align-items:center; gap:8px; padding:8px; border:1px solid var(--line); border-radius:8px; overflow-wrap:anywhere; }
    .file-item .file-name { flex:1; min-width:0; }
    .file-item button { flex-shrink:0; }
    .sync-state { padding:2px 0 10px; color:var(--muted); font-size:12px; }
    .sync-state.failed { color:var(--red); }
    .active-filters { display:flex; flex-wrap:wrap; gap:6px; margin:8px 0; }
    .form-error { position:relative; padding:10px; margin-bottom:10px; border-radius:8px; background:#fce8e6; color:var(--red); white-space:pre-wrap; }
    @media (max-width:600px) {
      .data-table.metal-table { min-width:0; display:block; }
      .metal-table thead { display:none; }
      .metal-table tbody { display:grid; gap:8px; }
      .metal-table tr { display:grid; grid-template-columns:1fr 1fr; padding:8px; border:1px solid var(--line); border-radius:8px; }
      .metal-table td { white-space:normal; border:0; min-width:0; overflow-wrap:anywhere; }
      .metal-table td::before { content:attr(data-label); display:block; font-size:10px; color:var(--muted); }
      .title-row { flex-wrap:wrap; } .file-item { flex-wrap:wrap; }
    }
    a { color:var(--blue); }
    @media (max-width:900px) { .filters,.filters.secondary { grid-template-columns:1fr 1fr; } .order { grid-template-columns:1fr 1fr; } .order-head,.order-plan,.primary-actions,.comment-box { grid-column:1/-1; } .actions { justify-content:flex-start; } }
    @media (max-width:600px) { header { padding:10px 12px; } main { padding:10px; } .filters,.filters.secondary,.grid { grid-template-columns:1fr; } .order { grid-template-columns:1fr 1fr; } .order-head,.order-plan,.primary-actions,.comment-box { grid-column:1/-1; } .summary { grid-template-columns:repeat(7,132px); } dialog.wide { width:calc(100vw - 12px); } .modal { padding:14px; } .data-table { min-width:720px; } .batch-bar { align-items:stretch; flex-direction:column; } .batch-bar .field { min-width:0; } }
    @media (max-width:380px) { .order { grid-template-columns:1fr; } .order > * { grid-column:1; } }
    @media (max-width:480px) { h1{font-size:17px;} .user .email{display:none;} }
    #createFiles .file-item,#addFilesList .file-item { flex-wrap:wrap; }
    .file-item .file-original { display:flex; align-items:center; gap:6px; flex-basis:100%; margin:0; font-size:13px; font-weight:400; }
    .file-original input[type=checkbox] { width:auto; margin:0; flex:0 0 auto; }
    .order { grid-template-columns:minmax(240px,1.4fr) minmax(150px,1fr) minmax(170px,1fr); }
    .order-plan,.primary-actions { grid-column:1/-1; }
    .tabs .tab { flex:1; min-width:0; white-space:normal; font-size:13px; }
    .main-toolbar { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }
    .main-toolbar #search { flex:1; min-width:150px; }
    .main-toolbar .app-menu { margin-left:auto; }
    .app-menu,.order-menu { position:relative; }
    .app-menu>summary,.order-menu>summary { list-style:none; cursor:pointer; padding:8px 12px; border:1px solid var(--line); border-radius:10px; background:white; }
    .app-menu>summary::-webkit-details-marker,.order-menu>summary::-webkit-details-marker { display:none; }
    .order-menu>summary { font-size:22px; line-height:1; }
    .menu-items { position:absolute; right:0; top:100%; z-index:20; display:grid; gap:4px; min-width:210px; max-width:calc(100vw - 40px); background:white; border:1px solid var(--line); border-radius:12px; padding:6px; box-shadow:0 6px 20px #0002; }
    .menu-items button { width:100%; text-align:left; white-space:normal; }
    .order-menu { margin-left:auto; flex:0 0 auto; }
    .title-row { flex-wrap:wrap; }
    .order-title { min-width:0; overflow-wrap:anywhere; flex:1 1 auto; }
    .manager-line,h2 { overflow-wrap:anywhere; }
    .tag,.choice { max-width:100%; overflow-wrap:anywhere; }
    .order { position:relative; overflow:visible; }
    .manager-line { margin-top:6px; font-size:13px; color:var(--muted); }
    .week-panel>summary { font-weight:650; cursor:pointer; }
    .week-controls { margin:10px 0; }
    .queue-controls { display:flex; align-items:flex-start; gap:8px; flex-wrap:wrap; }
    .queue-controls #queueView { width:auto; max-width:100%; }
    .queue-controls .advanced-filters { flex:1; min-width:110px; }
    .planning-fields>summary,.old-writeoffs>summary { cursor:pointer; padding:10px 0; font-weight:600; }
    #serviceDialog p { overflow-wrap:anywhere; }
    @media(max-width:900px) { .order { grid-template-columns:1fr 1fr; } }
    @media(max-width:600px) { .main-toolbar #search { order:3; flex-basis:100%; } .summary { grid-template-columns:repeat(7,118px); } .title-row { align-items:center; } .order-menu .menu-items { min-width:195px; } .queue-controls .filters.secondary { grid-template-columns:1fr; } }
    @media(max-width:380px) { .order { grid-template-columns:1fr; } }
    @media(max-width:600px) { .main-toolbar:has(#createBtn[hidden]) #search { order:0; flex:1 1 180px; width:0; } }
  
.auth-card{max-width:440px;margin:10vh auto;padding:24px}.auth-card input{margin:6px 0 16px}.auth-card button{width:100%}.auth-error{color:var(--red);white-space:pre-wrap}.admin-row{display:flex;flex-wrap:wrap;gap:8px;align-items:center;border-bottom:1px solid var(--line);padding:10px 0}.admin-row span{flex:1;overflow-wrap:anywhere}.admin-list{max-height:45vh;overflow:auto}.admin-form{margin-top:16px}#updateNotice{margin:8px 16px}
.queue-views{display:flex;flex-wrap:wrap;gap:6px;width:100%}.queue-filter{background:#f1f3f4;color:var(--muted);display:inline-flex;align-items:center;gap:7px;min-height:40px}.queue-filter.active{background:var(--blue);color:#fff}.queue-count{display:inline-block;padding:1px 6px;border-radius:20px;background:#0001;font-size:12px}.queue-help{margin:0 0 12px;max-width:100%;overflow-wrap:anywhere}.completion-hint{font-size:12px;color:var(--muted);align-self:center}.badge.received{background:#e8f0fe;color:#174ea6}.status[data-status="В работе"]{color:#137333;background:#e6f4ea}
@media(max-width:480px){.queue-views{display:grid;grid-template-columns:1fr 1fr}.queue-filter{justify-content:space-between;text-align:left;min-width:0;font-size:12px;padding:9px}.queue-filter:last-child{grid-column:1/-1}.completion-hint{flex-basis:100%}}
.analysis-filters{display:grid;grid-template-columns:repeat(2,minmax(120px,.7fr)) minmax(150px,1fr) minmax(150px,1fr) minmax(120px,.8fr) auto;gap:10px;align-items:end}.analysis-filters label{display:grid;gap:5px;min-width:0;font-size:12px;color:var(--muted)}.analysis-summary{margin:16px 0;display:grid;gap:6px}.analysis-summary strong{font-size:18px}.analysis-scroll{max-width:100%;overflow-x:auto}.analysis-table{font-size:13px}.analysis-table td{white-space:normal;overflow-wrap:anywhere;min-width:120px}.analysis-table td:last-child{min-width:155px}.analysis-order-link{background:transparent;text-align:left;padding:6px 0;overflow-wrap:anywhere}.analysis-written{display:inline-block;padding:4px 8px;border-radius:20px;white-space:nowrap;font-weight:650}.analysis-written.yes{color:#137333;background:#e6f4ea}.analysis-written.no{color:#b3261e;background:#fce8e6}.analysis-incomplete{color:#7c4a03;background:#fef7e0;border-radius:8px;padding:10px;margin:0}#analysisDetailExtra{margin-top:16px}#analysisPanel{min-width:0}#analysisDetail .file-list{display:flex;flex-wrap:wrap;gap:6px}
@media(max-width:900px){.analysis-filters{grid-template-columns:repeat(3,minmax(0,1fr))}}@media(max-width:600px){.analysis-filters{grid-template-columns:repeat(2,minmax(0,1fr))}.analysis-filters button{min-height:40px}.analysis-table td{font-size:12px;min-width:100px}.analysis-summary strong{font-size:16px}}
#analysisDetail .drawing-link{white-space:normal;overflow-wrap:anywhere;max-width:100%}

.analysis-swipe{display:none}@media(max-width:700px){.analysis-swipe{display:block}}
